Reputation: 81
I'm new to react and I'm currently working on a small change to an existing application.
I made the change and tested it locally. It's all good. both npm start and npm run build works without any errors. This application has a CI setup in Azure DevOps and when I check in the code the CI build failed. The log is below.
npm ERR! Windows_NT 6.3.9600
> react-scripts build
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "build"
npm ERR! node v6.9.1
Creating an optimized production build...
npm ERR! npm v3.10.8
Skipping static resource "D:/a/1/s/MyAppClient/build/static/js/main.b7fe64b2.js" (5.36 MB) - max size is 2.1 MB
npm ERR! code ELIFECYCLE
Failed to compile.
npm ERR! [email protected] build: `react-scripts build`
npm ERR! Exit status 1
static/js/main.b7fe64b2.js from UglifyJs
npm ERR!
Unexpected token: operator (>) [./~/file-type/index.js:2,0][static/js/main.b7fe64b2.js:51965,19]
npm ERR! Failed at the [email protected] build script 'react-scripts build'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the MyAppclient package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! react-scripts build
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs MyAppclient
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls MyAppclient
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! D:\a\1\s\MyAppClient\npm-debug.log
Found npm debug log, make sure the path matches with the one in npm's output: D:\a\1\s\MyAppClient\npm-debug.log
0 info it worked if it ends with ok
1 verbose cli [ 'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli 'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli 'run',
1 verbose cli 'build' ]
2 info using [email protected]
3 info using [email protected]
4 verbose run-script [ 'prebuild', 'build', 'postbuild' ]
5 info lifecycle [email protected]~prebuild: [email protected]
6 silly lifecycle [email protected]~prebuild: no script for prebuild, continuing
7 info lifecycle [email protected]~build: [email protected]
8 verbose lifecycle [email protected]~build: unsafe-perm in lifecycle true
9 verbose lifecycle [email protected]~build: PATH: C:\Program Files\nodejs\node_modules\npm\bin\node-gyp-bin;D:\a\1\s\MyAppClient\node_modules\.bin;C:\agents\2.142.1\externals\git\cmd;C:\ProgramData\Oracle\Java\javapath;C:\W
10 verbose lifecycle [email protected]~build: CWD: D:\a\1\s\MyAppClient
11 silly lifecycle [email protected]~build: Args: [ '/d /s /c', 'react-scripts build' ]
12 silly lifecycle [email protected]~build: Returned: code: 1 signal: null
13 info lifecycle [email protected]~build: Failed to exec build script
14 verbose stack Error: [email protected] build: `react-scripts build`
14 verbose stack Exit status 1
14 verbose stack at EventEmitter.<anonymous> (C:\Program Files\nodejs\node_modules\npm\lib\utils\lifecycle.js:255:16)
14 verbose stack at emitTwo (events.js:106:13)
14 verbose stack at EventEmitter.emit (events.js:191:7)
14 verbose stack at ChildProcess.<anonymous> (C:\Program Files\nodejs\node_modules\npm\lib\utils\spawn.js:40:14)
14 verbose stack at emitTwo (events.js:106:13)
14 verbose stack at ChildProcess.emit (events.js:191:7)
14 verbose stack at maybeClose (internal/child_process.js:877:16)
14 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)
15 verbose pkgid [email protected]
16 verbose cwd D:\a\1\s\MyAppClient
17 error Windows_NT 6.3.9600
18 error argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "build"
19 error node v6.9.1
20 error npm v3.10.8
21 error code ELIFECYCLE
22 error [email protected] build: `react-scripts build`
22 error Exit status 1
23 error Failed at the [email protected] build script 'react-scripts build'.
23 error Make sure you have the latest version of node.js and npm installed.
23 error If you do, this is most likely a problem with the MyAppclient package,
23 error not with npm itself.
23 error Tell the author that this fails on your system:
23 error react-scripts build
23 error You can get information on how to open an issue for this project with:
23 error npm bugs MyAppclient
23 error Or if that isn't available, you can get their info via:
23 error npm owner ls MyAppclient
23 error There is likely additional logging output above.
24 verbose exit [ 1, true ]
##[error]Error: Npm failed with return code: 1
##[section]Finishing: Build Client
I don't know what the issue is but I sense it must be around "Unexpected token: operator (>)"
Can you please let me know what am I missing?
Upvotes: 2
Views: 2681
Reputation: 6299
Unexpected token: operator (>)
usually happens when there is an arrow function (=>
) in the generated bundle and it executes in a js environment that doesn't support arrow functions (below ES6).
There is no straight forward solution to this. But you can try two things.
query-string
and its source code was not babel transpiled and had arrow functions in the code. I had to add a config in webpack to transpile that package as well (webpack doesn't transpile code in node_modules
unless you specify it explicitly).Upvotes: 4