Webpack脚本不会通过NPM运行,但如果直接粘贴到终端则会运行

时间:2017-04-02 21:21:02

标签: javascript node.js npm webpack

我正在使用Electron-React-Boilerplate并尝试运行npm run build-renderer但是当脚本看似已完成时我收到错误。

如果我直接从终端粘贴与build-renderer脚本关联的代码,则不会失败。

命令本身是:cross-env NODE_ENV=production node --trace-warnings -r babel-register ./node_modules/webpack/bin/webpack --display-error-details --config webpack.config.renderer.prod.js --progress --profile --colors

这是我失败时获得的完整输出。在我看来,这里没有任何东西可以帮助我诊断这个问题。

非常感谢任何建议或想法!

脚本输出

0 info it worked if it ends with ok
1 verbose cli [ 'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli   'C:\\Users\\Slapbox\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli   'run',
1 verbose cli   'build-renderer' ]
2 info using npm@4.2.0
3 info using node@v7.7.3
4 verbose run-script [ 'prebuild-renderer', 'build-renderer', 'postbuild-renderer' ]
5 info lifecycle myApp@1.1.0~prebuild-renderer: myApp@1.1.0
6 silly lifecycle myApp@1.1.0~prebuild-renderer: no script for prebuild-renderer, continuing
7 info lifecycle myApp@1.1.0~build-renderer: myApp@1.1.0
8 verbose lifecycle myApp@1.1.0~build-renderer: unsafe-perm in lifecycle true
9 verbose lifecycle myApp@1.1.0~build-renderer: PATH: C:\Users\Slapbox\AppData\Roaming\npm\node_modules\npm\bin\node-gyp-bin;C:\Projects\myApp\node_modules\.bin;C:\Users\Slapbox\.babun\cygwin\home\Slapbox\.local\bin;C:\Users\Slapbox\.babun\cygwin\usr\local\bin;C:\Users\Slapbox\.babun\cygwin\usr\local\bin;C:\Users\Slapbox\.babun\cygwin\usr\local\sbin;C:\Users\Slapbox\.babun\cygwin\home\Slapbox\.local\bin;C:\Users\Slapbox\.babun\cygwin\bin;C:\ProgramData\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0;C:\Program Files\Microsoft SQL Server\130\Tools\Binn;C:\Program Files (x86)\Windows Kits\8.1\Windows Performance Toolkit;C:\Program Files\MySQL\MySQL Utilities 1.6;C:\Program Files\Perforce;C:\Users\Slapbox\AppData\Local\Programs\Python\Python35-32\Scripts;C:\Users\Slapbox\AppData\Local\Programs\Python\Python35-32;C:\Users\Slapbox\.babun;C:\Users\Slapbox\AppData\Roaming\npm\node_modules\jshint\bin;C:\Program Files\Perforce\Server;C:\Users\Slapbox\AppData\Roaming\npm;C:\adb;C:\Program Files\nodejs;C:\Program Files (x86)\Microsoft VS Code\bin
10 verbose lifecycle myApp@1.1.0~build-renderer: CWD: C:\Projects\myApp
11 silly lifecycle myApp@1.1.0~build-renderer: Args: [ '/d /s /c',
11 silly lifecycle   'cross-env NODE_ENV=production node --trace-warnings -r babel-register ./node_modules/webpack/bin/webpack --display-error-details --config webpack.config.renderer.prod.js --progress --profile --colors' ]
12 silly lifecycle myApp@1.1.0~build-renderer: Returned: code: 2  signal: null
13 info lifecycle myApp@1.1.0~build-renderer: Failed to exec build-renderer script
14 verbose stack Error: myApp@1.1.0 build-renderer: `cross-env NODE_ENV=production node --trace-warnings -r babel-register ./node_modules/webpack/bin/webpack --display-error-details --config webpack.config.renderer.prod.js --progress --profile --colors`
14 verbose stack Exit status 2
14 verbose stack     at EventEmitter.<anonymous> (C:\Users\Slapbox\AppData\Roaming\npm\node_modules\npm\lib\utils\lifecycle.js:279:16)
14 verbose stack     at emitTwo (events.js:106:13)
14 verbose stack     at EventEmitter.emit (events.js:194:7)
14 verbose stack     at ChildProcess.<anonymous> (C:\Users\Slapbox\AppData\Roaming\npm\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:194:7)
14 verbose stack     at maybeClose (internal/child_process.js:899:16)
14 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)
15 verbose pkgid myApp@1.1.0
16 verbose cwd C:\Projects\myApp
17 error Windows_NT 6.1.7601
18 error argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\Slapbox\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "run" "build-renderer"
19 error node v7.7.3
20 error npm  v4.2.0
21 error code ELIFECYCLE
22 error errno 2
23 error myApp@1.1.0 build-renderer: `cross-env NODE_ENV=production node --trace-warnings -r babel-register ./node_modules/webpack/bin/webpack --display-error-details --config webpack.config.renderer.prod.js --progress --profile --colors`
23 error Exit status 2
24 error Failed at the myApp@1.1.0 build-renderer script 'cross-env NODE_ENV=production node --trace-warnings -r babel-register ./node_modules/webpack/bin/webpack --display-error-details --config webpack.config.renderer.prod.js --progress --profile --colors'.
24 error Make sure you have the latest version of node.js and npm installed.
24 error If you do, this is most likely a problem with the myApp package,
24 error not with npm itself.
24 error Tell the author that this fails on your system:
24 error     cross-env NODE_ENV=production node --trace-warnings -r babel-register ./node_modules/webpack/bin/webpack --display-error-details --config webpack.config.renderer.prod.js --progress --profile --colors
24 error You can get information on how to open an issue for this project with:
24 error     npm bugs myApp
24 error Or if that isn't available, you can get their info via:
24 error     npm owner ls myApp
24 error There is likely additional logging output above.
25 verbose exit [ 2, true ]

1 个答案:

答案 0 :(得分:1)

尝试在webpack.config.renderer.prod.js中删除此行:

new BabiliPlugin(),

有关详情,请参阅:https://github.com/chentsulin/electron-react-boilerplate/issues/816