无法从此文件中缩小代码(node_modules)

时间:2018-01-16 18:40:28

标签: javascript node.js reactjs npm

我正在尝试使用npm run build构建我的React项目,当我在控制台中运行此命令时出现以下错误:

无法缩小此文件中的代码:

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 npm@5.3.0
3 info using node@v8.4.0
4 verbose run-script [ 'prebuild', 'build', 'postbuild' ]
5 info lifecycle frontend@0.1.0~prebuild: frontend@0.1.0
6 info lifecycle frontend@0.1.0~build: frontend@0.1.0
7 verbose lifecycle frontend@0.1.0~build: unsafe-perm in lifecycle true
8 verbose lifecycle frontend@0.1.0~build: PATH: C:\Program Files\nodejs\node_modules\npm\bin\node-gyp-bin;C:\Users\sande\Desktop\Project-5-6\frontend\node_modules\.bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\xampp\php;C:\ProgramData\ComposerSetup\bin;C:\Program Files\Microsoft SQL Server\130\Tools\Binn\;C:\Program Files\dotnet\;C:\Program Files\nodejs\;C:\PostgreSQL\pg96\bin;C:\Program Files\Git\cmd;C:\Users\sande\AppData\Local\Microsoft\WindowsApps;C:\Users\sande\AppData\Local\atom\bin;C:\Users\sande\AppData\Local\GitHubDesktop\bin;C:\Users\sande\AppData\Roaming\Composer\vendor\bin;C:\Users\sande\AppData\Roaming\npm;C:\Program Files\Microsoft VS Code\bin;C:\Users\sande\AppData\Local\Microsoft\WindowsApps;
9 verbose lifecycle frontend@0.1.0~build: CWD: C:\Users\sande\Desktop\Project-5-6\frontend
10 silly lifecycle frontend@0.1.0~build: Args: [ '/d /s /c', 'react-scripts build' ]
11 silly lifecycle frontend@0.1.0~build: Returned: code: 1  signal: null
12 info lifecycle frontend@0.1.0~build: Failed to exec build script
13 verbose stack Error: frontend@0.1.0 build: `react-scripts build`
13 verbose stack Exit status 1
13 verbose stack     at EventEmitter.<anonymous> (C:\Program Files\nodejs\node_modules\npm\lib\utils\lifecycle.js:289:16)
13 verbose stack     at emitTwo (events.js:125:13)
13 verbose stack     at EventEmitter.emit (events.js:213:7)
13 verbose stack     at ChildProcess.<anonymous> (C:\Program Files\nodejs\node_modules\npm\lib\utils\spawn.js:40:14)
13 verbose stack     at emitTwo (events.js:125:13)
13 verbose stack     at ChildProcess.emit (events.js:213:7)
13 verbose stack     at maybeClose (internal/child_process.js:927:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:211:5)
14 verbose pkgid frontend@0.1.0
15 verbose cwd C:\Users\sande\Desktop\Project-5-6\frontend
16 verbose Windows_NT 10.0.16299
17 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "build"
18 verbose node v8.4.0
19 verbose npm  v5.3.0
20 error code ELIFECYCLE
21 error errno 1
22 error frontend@0.1.0 build: `react-scripts build`

我检查了index.js文件,但是在第4行有通知的类声明。

生成日志文件包含以下内容:

{{1}}

当我跑步&#34; npm start&#34;在浏览器中查看项目一切正常。我已经尝试更新npm,react和react-notification-alert。所有这些都导致了同样的错误。

有人可以帮帮我吗?

1 个答案:

答案 0 :(得分:0)

简单地发布图书馆并非生产就绪。

您必须分叉并删除第4行:

import './animate.css';

不仅它暗示了特殊的webpack配置,而且该文件根本不存在于库中,非常有趣!

实际上,将代码直接复制到项目中并忘记

会更容易