I am trying to build assets for a symfony project by running npm run build
. Here is my package.json
:
{
"devDependencies": {
"@babel/core": "^7.17.0",
"@babel/preset-env": "^7.16.0",
"@hotwired/stimulus": "^3.0.0",
"@symfony/stimulus-bridge": "^3.2.0",
"@symfony/webpack-encore": "^4.1.2",
"core-js": "^3.23.0",
"regenerator-runtime": "^0.13.9",
"webpack": "^5.74.0",
"webpack-cli": "^4.10.0",
"webpack-notifier": "^1.15.0"
},
"license": "UNLICENSED",
"private": true,
"scripts": {
"dev-server": "encore dev-server",
"dev": "webpack --mode development --watch",
"watch": "encore dev --watch",
"build": "encore production --progress"
},
"dependencies": {
"chart.js": "^3.9.1"
}
}
The error:
npm run build
> build
> encore production --progress
Running webpack ...
[webpack-cli] Failed to load '/home/lex/Desktop/research/UofSCNutrientStudy/webpack.config.js' config
[webpack-cli] /home/lex/Desktop/research/UofSCNutrientStudy/node_modules/css-minimizer-webpack-plugin/node_modules/jest-worker/build/index.js:109
enableWorkerThreads: this._options.enableWorkerThreads ?? false,
^
SyntaxError: Unexpected token '?'
at wrapSafe (internal/modules/cjs/loader.js:915:16)
at Module._compile (internal/modules/cjs/loader.js:963:27)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
at Module.load (internal/modules/cjs/loader.js:863:32)
at Function.Module._load (internal/modules/cjs/loader.js:708:14)
at Module.require (internal/modules/cjs/loader.js:887:19)
at require (internal/modules/cjs/helpers.js:74:18)
at Object.<anonymous> (/home/lex/Desktop/research/UofSCNutrientStudy/node_modules/css-minimizer-webpack-plugin/dist/index.js:17:5)
at Module._compile (internal/modules/cjs/loader.js:999:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
What I have tried:
I have looked at answers like this: "npm run build" fails with SyntaxError:Unexpected token and tried to see what file was causing the issue, but cannot seem to find it. Please let me know if any other information would be helpful. It doesn't seem like there is a public/build/manifest.json
file either, but not sure if that is related.
CodePudding user response:
@hous Is correct. I switched to node 16 and everything works.