Copy-webpack-plugin: Failed to install V6, whereas V5 works - SyntaxError: Unexpected token {

Created on 1 Jul 2020  路  3Comments  路  Source: webpack-contrib/copy-webpack-plugin

  • Operating System: Ubuntu 16
  • Node Version: try at first with V8, then I switch to V14, still occurs
  • NPM Version: V6
  • webpack Version: 4.42
  • copy-webpack-plugin Version: 6.0.3

Expected Behavior

If I install the V5 version of copy-webpack-plugin, the postinstall of my app works :

[npm i...]
[npm postinstall : building DLL...]
[email protected] build:dll /home/lmieulet/CS/rs-dev/rs-frontend/webapp
> webpack --mode=development --progress --config webpack.dev.dll.config.js --display-error-details

@regardsoss/webpack-config-front |  Generate config with mode = dll
@regardsoss/webpack-config-front |  Working directory = /home/lmieulet/CS/rs-dev/rs-frontend/webapp
Hash: 8092e7f69889ffa6881d
Version: webpack 4.42.0
Time: 30403ms
Built at: 2020-07-01 16:44:37
[...]

Actual Behavior

By just adding

const CopyPlugin = require('copy-webpack-plugin');

By running any webpack command I have the following:

$ npm run postinstall

> [email protected] postinstall /home/lmieulet/CS/rs-dev/rs-frontend/webapp
> npm run build:dll && npm run build:production-dll && npm run build:mizar


> [email protected] build:dll /home/lmieulet/CS/rs-dev/rs-frontend/webapp
> webpack --mode=development --progress --config webpack.dev.dll.config.js --display-error-details

/home/lmieulet/CS/rs-dev/rs-frontend/webapp/node_modules/copy-webpack-plugin/node_modules/p-limit/index.js:30
                } catch {}
                        ^

SyntaxError: Unexpected token {
    at NativeCompileCache._moduleCompile (/home/lmieulet/CS/rs-dev/rs-frontend/webapp/node_modules/v8-compile-cache/v8-compile-cache.js:240:18)
    at Module._compile (/home/lmieulet/CS/rs-dev/rs-frontend/webapp/node_modules/v8-compile-cache/v8-compile-cache.js:186:36)
    at Object.Module._extensions..js (module.js:664:10)
    at Module.load (module.js:566:32)
    at tryModuleLoad (module.js:506:12)
    at Function.Module._load (module.js:498:3)
    at Module.require (module.js:597:17)
    at require (/home/lmieulet/CS/rs-dev/rs-frontend/webapp/node_modules/v8-compile-cache/v8-compile-cache.js:161:20)
    at Object.<anonymous> (/home/lmieulet/CS/rs-dev/rs-frontend/webapp/node_modules/copy-webpack-plugin/dist/index.js:10:38)
    at Module._compile (/home/lmieulet/CS/rs-dev/rs-frontend/webapp/node_modules/v8-compile-cache/v8-compile-cache.js:192:30)
    at Object.Module._extensions..js (module.js:664:10)
    at Module.load (module.js:566:32)
    at tryModuleLoad (module.js:506:12)
    at Function.Module._load (module.js:498:3)
    at Module.require (module.js:597:17)
    at require (/home/lmieulet/CS/rs-dev/rs-frontend/webapp/node_modules/v8-compile-cache/v8-compile-cache.js:161:20)
    at Object.<anonymous> (/home/lmieulet/CS/rs-dev/rs-frontend/webapp/node_modules/copy-webpack-plugin/dist/cjs.js:3:16)
    at Module._compile (/home/lmieulet/CS/rs-dev/rs-frontend/webapp/node_modules/v8-compile-cache/v8-compile-cache.js:192:30)
    at Object.Module._extensions..js (module.js:664:10)
    at Module.load (module.js:566:32)
    at tryModuleLoad (module.js:506:12)
    at Function.Module._load (module.js:498:3)
    at Module.require (module.js:597:17)
    at require (/home/lmieulet/CS/rs-dev/rs-frontend/webapp/node_modules/v8-compile-cache/v8-compile-cache.js:161:20)
    at Object.<anonymous> (/home/lmieulet/CS/rs-dev/rs-frontend/webapp/webpack-config-front/src/app/webpack.common.config.js:6:20)
    at Module._compile (/home/lmieulet/CS/rs-dev/rs-frontend/webapp/node_modules/v8-compile-cache/v8-compile-cache.js:192:30)
    at Object.Module._extensions..js (module.js:664:10)
    at Module.load (module.js:566:32)
    at tryModuleLoad (module.js:506:12)
    at Function.Module._load (module.js:498:3)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] build:dll: `webpack --mode=development --progress --config webpack.dev.dll.config.js --display-error-details`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] build:dll script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/lmieulet/.npm/_logs/2020-07-01T14_35_06_123Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] postinstall: `npm run build:dll && npm run build:production-dll && npm run build:mizar`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/lmieulet/.npm/_logs/2020-07-01T14_35_06_175Z-debug.log

How Do We Reproduce?

  • clone our app
  • add "copy-webpack-plugin": "^6.0.3", to webapp/webpack-config-front/package.json
  • add const CopyPlugin = require('copy-webpack-plugin'); into webapp/webpack-config-front/src/app/webpack.common.config.js
  • run npm i, then on postinstall it will break

I'm sorry but our app is developped internaly and updates will be published in few months (when customer ask us to do it), but It should do the same behavior. At least somebody heard about this ? I will pin to V5 for now

Webpack dependencies

    "autoprefixer": "^9.7.4",
    "clean-webpack-plugin": "^3.0.0",
    "copy-webpack-plugin": "^6.0.3",
    "css-loader": "^3.4.2",
    "file-loader": "6.0.0",
    "fs-extra": "^8.1.0",
    "html-webpack-plugin": "^3.2.0",
    "json-loader": "~0.5.7",
    "mini-css-extract-plugin": "^0.9.0",
    "postcss-loader": "~3.0.0",
    "stats-webpack-plugin": "^0.7.0",
    "strip-pragma-loader": "^1.0.0",
    "style-loader": "~1.1.3",
    "terser-webpack-plugin": "^2.3.5",
    "thread-loader": "^2.1.3",
    "url-loader": "~4.0.0",
    "webpack": "4.42.0",
    "webpack-dev-server": "~3.10.3",
    "webpack-merge": "4.2.2",
    "webpack-node-externals": "~1.7.2",
    "webpack-shell-plugin": "^0.5.0"

Most helpful comment

All 3 comments

Not related to copy-webpack-plugin, maybe something with env, I can't reproduce locally, problem with your environment

True ! I've installed the last node version but someway I'm still have old node

$ node -v
v8.14.0
Was this page helpful?
0 / 5 - 0 ratings