Copy-webpack-plugin: permission denied, mkdir

Created on 4 May 2016  路  21Comments  路  Source: webpack-contrib/copy-webpack-plugin

After upgrading from version 1.1.1 to 2.0.0 I get the following error... no other configuration has changed.

Unhandled rejection Error: EACCES: permission denied, mkdir '/_karma_webpack_'
    at Error (native)

Is this a known issue? Do you have any idea what might be going on? I looked around but couldn't find anything.
Downgrading back to 1.1.1 works as before, which is pretty weird given the error is related to permission denied.

Most helpful comment

fix it. DO NOT add slash at front.
{ from: path.join(__dirname, '../src/_locales'), to: '/_locales' } ====> wrong, error permission denied
{ from: path.join(__dirname, '../src/_locales'), to: '_locales' } ====> right

All 21 comments

It looks like it's trying to create _karma_webpack_ in your system's root directory (which would require sudo permissions). This looks like a bug, but I'll need to see your CopyWebpackPlugin config to reproduce it.

Hmm. Ok. Our configuration is nothing special, just a bunch of from/to objects:

new CopyWebpackPlugin([
    {
        from: path.join(__dirname, "resources", "some_dir"),
        to: "some_dir"
    },
    ... about 10 of these
]

Looks like it only happens when executing tests. so there is some combination of plugins messing up somewhere. I'll dig around a bit and let you know if I figure out some more information (as I don't have anything else right now).

Somehow the issue solved itself. No idea why/how. Closing this.

Edit: this was a false alarm. I had issues with shrinkwrap and the update didn't go through.

Looks like the issue is still present. (I'm a team-mate of @jseminck )

The problem appeared when upgrading from copy-webpack-plugin 1.1.1 to 2.0.0 (same issue with latest 2.1.3).

Solved it by disabling the plugin for Karma (we don't really need copy-files for our unit-tests anyway).

We are also experiencing this issue. We've tried rm -rf node_modules && npm install, but that didn't help. Downgraded to 1.1.1 until this issue is resolved.

Can this issue please be re-opened, as it seems like we are multiple people experiencing it?

I never write directly to the filesystem in v3.0.0, so please try with that version.

3.0.0 seems to work for us, although we already used another workaround which we will probably keep (disable plugins for our tests).

I'm having this issue on v3.0.1, so I would guess that @jseminck's problem was solved by disabling the plugin rather than the version bump

Also having same issue:

 95% emittingError: EACCES: permission denied, mkdir '/locales'
    at Error (native)

+1, anyone fix it ? "version": "3.0.1"

fix it. DO NOT add slash at front.
{ from: path.join(__dirname, '../src/_locales'), to: '/_locales' } ====> wrong, error permission denied
{ from: path.join(__dirname, '../src/_locales'), to: '_locales' } ====> right

module.exports = {
    entry: "./main.js",
    output: {
        path: "/build",
        filename: "build.js"
    },

If I remove / from the path, webpack-dev-server throws an error,
The provided value "build" is not an absolute path

Any help?

Per the webpack docs , changing output.path to __dirname + "/your-export-directory" should resolve this

Yep, this should be closed based on @jbolotin's comment, worked for me.

yes I also faced this issue in latest version webpack, then I found that by removing the "/" from the beginning of the path`s, resolved the issue.
firstly I have done this:
let path = require('path'),
HtmlWebpackPlugin = require('html-webpack-plugin');
module.exports = {
entry: './index.js',
output: {
filename: '[name]-bundle-[hash].js',
path: path.resolve(__dirname,'/public')
},
module: {
rules:[{
test: /.js$/,
exclude: /node_modules/,
use: 'jshint-loader'
}]
},
plugins: [
new HtmlWebpackPlugin({
template: "/public/index.html"
})
]
}

Then by removing "/"
let path = require('path'),
HtmlWebpackPlugin = require('html-webpack-plugin');
module.exports = {
entry: './index.js',
output: {
filename: '[name]-bundle-[hash].js',
path: path.resolve(__dirname,'public')
},
module: {
rules:[{
test: /.js$/,
exclude: /node_modules/,
use: 'jshint-loader'
}]
},
plugins: [
new HtmlWebpackPlugin({
template: "public/index.html"
})
]
}

@jseminck please create separetly issue and use ```js for code, Thanks!

I think you tagged the wrong person 馃槃

@jseminck oh sorry :smile:

@hackgeeks ping please see above posts

This worked for me:

      new CopyWebpackPlugin(
        [
          {
            context: './src/',
            from: '**/*.html',
            to: './',
            force: true,
          },
        ],
        {
          copyUnmodified: true,
        },
      ),

For me, this issue was caused by a wrong publicPath setting, before it was

output: {
    filename: '[name]/app.[hash].js',
    path: path.join(__dirname + '/dist'),
    publicPath: 'http://127.0.0.1:8089',
},

It works after changing http://127.0.0.1:8089 to http://127.0.0.1:8089/.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

richmeij picture richmeij  路  5Comments

niksmac picture niksmac  路  3Comments

dmarcautan picture dmarcautan  路  5Comments

ietabhi picture ietabhi  路  5Comments

cletusw picture cletusw  路  5Comments