带有日志的npm启动脚本的Webpack问题

时间:2018-02-07 10:32:26

标签: npm webpack package.json

我总是遇到像在tuts那样做同样事情的问题,但对他们来说工作正常,对我来说总是问题。一切都很好,但我有错误

LOG:

0 info it worked if it ends with ok
1 verbose cli [ '/usr/bin/node', '/usr/bin/npm', 'run', 'build' ]
2 info using npm@5.6.0
3 info using node@v9.5.0
4 verbose run-script [ 'prebuild', 'build', 'postbuild' ]
5 info lifecycle worldwide_ocean@1.0.0~prebuild: worldwide_ocean@1.0.0
6 info lifecycle worldwide_ocean@1.0.0~build: worldwide_ocean@1.0.0
7 verbose lifecycle worldwide_ocean@1.0.0~build: unsafe-perm in lifecycle true
8 verbose lifecycle worldwide_ocean@1.0.0~build: PATH: /usr/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/home/thetanadu/Dokumenty/codetemp/worldwide_ocean/node_modules/.bin:/usr/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/home/thetanadu/Dokumenty/codetemp/worldwide_ocean/node_modules/.bin:/home/thetanadu/bin:/home/thetanadu/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
9 verbose lifecycle worldwide_ocean@1.0.0~build: CWD: /home/thetanadu/Dokumenty/codetemp/worldwide_ocean
10 silly lifecycle worldwide_ocean@1.0.0~build: Args: [ '-c',
10 silly lifecycle   'webpack -d && webpack-dev-server -content-base src/ --inline --hot --port 1234' ]
11 silly lifecycle worldwide_ocean@1.0.0~build: Returned: code: 1  signal: null
12 info lifecycle worldwide_ocean@1.0.0~build: Failed to exec build script
13 verbose stack Error: worldwide_ocean@1.0.0 build: `webpack -d && webpack-dev-server -content-base src/ --inline --hot --port 1234`
13 verbose stack Exit status 1
13 verbose stack     at EventEmitter.<anonymous> (/usr/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:285:16)
13 verbose stack     at EventEmitter.emit (events.js:160:13)
13 verbose stack     at ChildProcess.<anonymous> (/usr/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
13 verbose stack     at ChildProcess.emit (events.js:160:13)
13 verbose stack     at maybeClose (internal/child_process.js:943:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:220:5)
14 verbose pkgid worldwide_ocean@1.0.0
15 verbose cwd /home/thetanadu/Dokumenty/codetemp/worldwide_ocean
16 verbose Linux 4.13.0-32-generic
17 verbose argv "/usr/bin/node" "/usr/bin/npm" "run" "build"
18 verbose node v9.5.0
19 verbose npm  v5.6.0
20 error code ELIFECYCLE
21 error errno 1
22 error worldwide_ocean@1.0.0 build: `webpack -d && webpack-dev-server -content-base src/ --inline --hot --port 1234`
22 error Exit status 1
23 error Failed at the worldwide_ocean@1.0.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 ]

package.json #scripts

"scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "start": "npm run build",
    "build": "webpack -d && webpack-dev-server -content-base src/ --inline --hot --port 1234"
  }

命令是1:1并且对他来说正在编译,但不适合我,我试图查看这个日志,但对我来说,它没有说清楚:/

1 个答案:

答案 0 :(得分:0)

这取决于您的开发脚本。如果您使用的是webpack-dev-server,那么您可以在packages.json中尝试这些命令:

  "scripts": {
    "start": "start npm run start:client",
    "start:client": "webpack-dev-server"
     ...
  },

可以在CLI中调用build命令 - webpack -p或不使用-p