问题
Have spent last 3 hours trying to get my reactjs project to build... have removed package.json / node-modules, rebuild using npm install. Had to rebuild all my scss links for some reason, finally have development server running fine, but when i run NPM RUN BUILD i get the following error...
> react-scripts build
Creating an optimized production build...
Failed to compile.
Parse error on line 1:
^
Expecting "CALC", "LPAREN", "SUB", "NUMBER", "FUNCTION", "LENGTH", "ANGLE", "TIME", "FREQ", "RES", "EMS", "EXS", "CHS", "REMS", "VHS", "VWS", "VMINS", "VMAXS", "PERCENTAGE", "expression", "math_expression", "value", "function", "css_value", got unexpected end of input
CompileError: Begins at CSS selector undefined
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! 2020site@0.1.0 build: `react-scripts build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the 2020site@0.1.0 build 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! /Users/grahams/.npm/_logs/2020-01-15T12_55_32_296Z-debug.log
and this is what the log fine outputs
0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/bin/node', '/usr/local/bin/npm', 'run', 'build' ]
2 info using npm@6.13.6
3 info using node@v8.11.3
4 verbose run-script [ 'prebuild', 'build', 'postbuild' ]
5 info lifecycle 2020site@0.1.0~prebuild: 2020site@0.1.0
6 info lifecycle 2020site@0.1.0~build: 2020site@0.1.0
7 verbose lifecycle 2020site@0.1.0~build: unsafe-perm in lifecycle true
8 verbose lifecycle 2020site@0.1.0~build: PATH: /usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/Users/grahams/Desktop/docker-apache-php5/htdocs/2020DotCom-2019-React/node_modules/.bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin
9 verbose lifecycle 2020site@0.1.0~build: CWD: /Users/grahams/Desktop/docker-apache-php5/htdocs/2020DotCom-2019-React
10 silly lifecycle 2020site@0.1.0~build: Args: [ '-c', 'react-scripts build' ]
11 silly lifecycle 2020site@0.1.0~build: Returned: code: 1 signal: null
12 info lifecycle 2020site@0.1.0~build: Failed to exec build script
13 verbose stack Error: 2020site@0.1.0 build: `react-scripts build`
13 verbose stack Exit status 1
13 verbose stack at EventEmitter.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:332:16)
13 verbose stack at emitTwo (events.js:126:13)
13 verbose stack at EventEmitter.emit (events.js:214:7)
13 verbose stack at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
13 verbose stack at emitTwo (events.js:126:13)
13 verbose stack at ChildProcess.emit (events.js:214:7)
13 verbose stack at maybeClose (internal/child_process.js:925:16)
13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
14 verbose pkgid 2020site@0.1.0
15 verbose cwd /Users/grahams/Desktop/docker-apache-php5/htdocs/2020DotCom-2019-React
16 verbose Darwin 16.7.0
17 verbose argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "build"
18 verbose node v8.11.3
19 verbose npm v6.13.6
20 error code ELIFECYCLE
21 error errno 1
22 error 2020site@0.1.0 build: `react-scripts build`
22 error Exit status 1
23 error Failed at the 2020site@0.1.0 build script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]
Can anyone advise as how to get project working...
回答1:
There is a function called printBuildError
in react-dev-utils
. Modify this function to print out the stack trace (err.stack
), and this will give you an idea of exactly what's not compiling.
来源:https://stackoverflow.com/questions/59752057/npm-run-build-failed-to-compile-cannot-get-to-build-reactjs-project