Answer the question
In order to leave comments, you need to log in
Why does the __dirname variable show the wrong path?
In webpack 4, I created a src folder and an index.j file in it, in which I wrote alert(__dirname);
In the console, I run webpack --mode production, then webpack-dev-server --mode development.
And in the browser alert gives me "/".
Although __dirname is the path to the folder with the file in which it is written and should be src
Answer the question
In order to leave comments, you need to log in
target: 'node',
node: {
__dirname: false,
}
plugins: [
new webpack.DefinePlugin({
$dirname: '__dirname',
}),
]
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question