Unable to run webpack from a subdirectory in my project. This is the error I'm getting: Error: EACCES, open '/build/bundle.js'
And this is the webpack configuration file:
module.exports = {
entry: ['./app.ts'],
output: {
filename: 'bundle.js',
path: '/build'
},
resolve: {
extensions: ['', '.ts', '.js' ]
},
devtool: 'source-map',
module: {
loaders: [
{ test: /\.ts$/, loader: 'ts?sourceMap!ts-jsx' }
]
}
};
Trying to use the command: 'sudo chown -R whoami
~/.npm' didn't help.
When webpack bundles your source code, it can become difficult to track down errors and warnings to their original location. For example, if you bundle three source files ( a.js, b.js, and c.js) into one bundle ( bundle.js) and one of the source files contains an error, the stack trace will simply point to bundle.js.
First, we can install jQuery using NPM: After that, we can change our custom JavaScript (App.js) file to: Now it’s time for Webpack. Open up the directory in a terminal and run: A JavaScript bundle will be created in our build directory in the project folder. We can link our bundled JavaScript file in our HTML, like so:
The minimum supported Node.js version to run webpack 5 is 10.13.0 (LTS) First let's create a directory, initialize npm, install webpack locally, and install the webpack-cli (the tool used to run webpack on the command line):
Nevertheless with default settings of npm (without exact-save = true) build gets corrupted automatically since webpack-cli is major update and webpack 4.20.0 is not. Sorry, something went wrong. Please read CHANGELOG https://github.com/webpack/webpack/releases/tag/v4.20.0
A late answer, but it looks like you're trying to build in the root of the system (/build
). For older versions of webpack use ./build
on the property path. For the latest version of webpack (3.0 as today) path: path.resolve(__dirname, 'dist'),
should work.
Webpack is trying to write to the /build directory. You do not seem to have permissions to write to it. You need to do sudo chown `whoami` /build
in order to be able to write to it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With