symfony / webpack-encore

A simple but powerful API for processing & compiling assets built around Webpack
https://symfony.com/doc/current/frontend.html
MIT License
2.23k stars 199 forks source link

npm run dev fails with "Invalid regular expression" error #873

Open SDPrio opened 3 years ago

SDPrio commented 3 years ago

I have set up a new Symfony 5.2 project and add Webpack Encore. The project uses a shared Server with no root access using npm 5.6.0 and node 9.9.0. As far as I know the Server runs on a 32bit CentOS Version, so this seems to be the highest supported versions of npm and node. Yarn is not available on this server.

// setup new Symfony 5.2 project
symfony new sym5 --version=5.2 --full
...
cd sym5

// add Webpack Encore
composer require symfony/webpack-encore-bundle
npm install
...

Installations works without any problems. I have made no changes to the webpack.config.js and asset/ files which have been automatically created. Running npm run dev fails:

npm run dev

> @ dev /customers/123/webpages/sym5
> encore dev

Running webpack ...

/customers/123/webpages/sym5/node_modules/camelcase/index.js:37
    return input.replace(/[_.\- ]+([\p{Alpha}\p{N}_]|$)/gu, (_, p1) => p1.toLocaleUpperCase(options.locale))
                 ^

SyntaxError: Invalid regular expression: /[_.\- ]+([\p{Alpha}\p{N}_]|$)/: Invalid escape
    at postProcess (/customers/123/webpages/sym5/node_modules/camelcase/index.js:37:15)
    at camelCase (/customers/123/webpages/sym5/node_modules/camelcase/index.js:86:9)
    at getAssetKind (/customers/123/webpages/sym5/node_modules/assets-webpack-plugin/dist/lib/getAssetKind.js:9:10)
    at /customers/123/webpages/sym5/node_modules/assets-webpack-plugin/dist/index.js:97:26
    at Array.reduce (<anonymous>)
    at /customers/123/webpages/sym5/node_modules/assets-webpack-plugin/dist/index.js:91:30
    at Array.reduce (<anonymous>)
    at afterEmit (/customers/123/webpages/sym5/node_modules/assets-webpack-plugin/dist/index.js:78:27)
    at AsyncSeriesHook.eval [as callAsync] (eval at create (/customers/123/webpages/sym5/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:20:1)
    at AsyncSeriesHook.lazyCompileHook (/customers/123/webpages/sym5/node_modules/tapable/lib/Hook.js:154:20)
    at asyncLib.forEachLimit.err (/customers/123/webpages/sym5/node_modules/webpack/lib/Compiler.js:482:27)
    at /customers/123/webpages/sym5/node_modules/neo-async/async.js:2818:7
    at done (/customers/123/webpages/sym5/node_modules/neo-async/async.js:3522:9)
    at AsyncSeriesHook.eval [as callAsync] (eval at create (/customers/123/webpages/sym5/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:6:1)
    at outputFileSystem.writeFile.err (/customers/123/webpages/sym5/node_modules/webpack/lib/Compiler.js:464:33)
    at /customers/123/webpages/sym5/node_modules/graceful-fs/graceful-fs.js:61:14
    at FSReqWrap.oncomplete (fs.js:153:20)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @ dev: `encore dev`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the @ dev 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!     /customers/123/.npm/_logs/2020-12-07T12_46_26_301Z-debug.log

Since the error is not reported in any my custom files, I assume that this is a problem of Node.js / Webpack itself? Is this correct?

I found another issue which says, that node v8 should be the min. requirement. Thus using v9.9.0 should be no problem, should it?

Is there anything I can do to find the actual cause and to solve the problem?


// Content of /customers/123/.npm/_logs/2020-12-07T12_46_26_301Z-debug.log

0 info it worked if it ends with ok
1 verbose cli [ '/customers/123/bin/nodejs/node-v9.9.0/bin/node',
1 verbose cli   '/customers/123/bin/nodejs/node-v9.9.0/bin/npm',
1 verbose cli   'run',
1 verbose cli   'dev' ]
2 info using npm@5.6.0
3 info using node@v9.9.0
4 verbose run-script [ 'predev', 'dev', 'postdev' ]
5 info lifecycle @~predev: @
6 info lifecycle @~dev: @
7 verbose lifecycle @~dev: unsafe-perm in lifecycle true
8 verbose lifecycle @~dev: PATH: /customers/123/bin/nodejs/node-v9.9.0/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/customers/123/webpages/sym5/node_modules/.bin:/customers/123/bin/:/customers/123/bin/nodejs/node-v9.9.0/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/customers/123/.gem/bin
9 verbose lifecycle @~dev: CWD: /customers/123/webpages/sym5
10 silly lifecycle @~dev: Args: [ '-c', 'encore dev' ]
11 silly lifecycle @~dev: Returned: code: 1  signal: null
12 info lifecycle @~dev: Failed to exec dev script
13 verbose stack Error: @ dev: `encore dev`
13 verbose stack Exit status 1
13 verbose stack     at EventEmitter.<anonymous> (/customers/123/bin/nodejs/node-v9.9.0/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:285:16)
13 verbose stack     at EventEmitter.emit (events.js:180:13)
13 verbose stack     at ChildProcess.<anonymous> (/customers/123/bin/nodejs/node-v9.9.0/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
13 verbose stack     at ChildProcess.emit (events.js:180:13)
13 verbose stack     at maybeClose (internal/child_process.js:936:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:220:5)
14 verbose pkgid @
15 verbose cwd /customers/123/webpages/sym5
16 verbose Linux 3.18.117-pvops-xen-x64
17 verbose argv "/customers/123/bin/nodejs/node-v9.9.0/bin/node" "/customers/123/bin/nodejs/node-v9.9.0/bin/npm" "run" "dev"
18 verbose node v9.9.0
19 verbose npm  v5.6.0
20 error code ELIFECYCLE
21 error errno 1
22 error @ dev: `encore dev`
22 error Exit status 1
23 error Failed at the @ dev script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]
Kocal commented 3 years ago

Encore and its dependencies require at least Node.js 10, but you are using Node.js 9.

Given your stacktrace, your error is coming from the camelcase module where some people already faced this kind of issue because they were not using Node.js 10 (at least):