NPM 运行构建无法编译 - 无法构建 reactjs 项目 [英] NPM run build failed to compile - cannot get to build reactjs project

查看:111
本文介绍了NPM 运行构建无法编译 - 无法构建 reactjs 项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

过去 3 个小时试图让我的 reactjs 项目构建...已经删除了 package.json/node-modules,使用 npm install 重建.由于某种原因不得不重建我所有的 scss 链接,最终开发服务器运行良好,但是当我运行 NPM RUN BUILD 时,我收到以下错误...

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...

推荐答案

react-dev-utils 中有一个名为 printBuildError 的函数.修改此函数以打印堆栈跟踪 (err.stack),这将使您确切了解未编译的内容.

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.

这篇关于NPM 运行构建无法编译 - 无法构建 reactjs 项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆