Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error: EACCES, open '/build/bundle.js' when running webpack

Tags:

npm

webpack

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.

like image 210
Ravit Avatar asked Apr 14 '15 16:04

Ravit


People also ask

What happens when you bundle your source code in Webpack?

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.

How to install jQuery with Webpack?

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:

How to run Webpack 5 on Node JS?

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):

Why is my Webpack-CLI build getting corrupted?

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


2 Answers

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.

like image 110
Gabriel G. Avatar answered Oct 20 '22 22:10

Gabriel G.


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.

like image 40
Bubba Raskin Avatar answered Oct 20 '22 22:10

Bubba Raskin