从npm-run-script运行时,node命令失败

时间:2017-01-04 17:46:09

标签: javascript node.js jasmine

我在通过package.json运行节点脚本时遇到了一些奇怪的行为,但它从终端运行良好。

如果我从bash shell运行以下任一项,它们就可以工作。

node --harmony-async-await index.js
node --harmony-async-await jasmine.js

但是如果我将以下内容添加到我的package.json文件中:

"scripts": {
  "start": "node --harmony-async-await index.js",
  "test": "node --harmony-async-await jasmine.js"
}

启动脚本运行正常,但是当我运行测试脚本时出错,我正在运行节点v7.3.0。以下是npm-debug.log的输出:

0 info it worked if it ends with ok
1 verbose cli [ '/Users/marktyers/.nvm/versions/node/v7.3.0/bin/node',
1 verbose cli   '/Users/marktyers/.nvm/versions/node/v7.3.0/bin/npm',
1 verbose cli   'run',
1 verbose cli   'test' ]
2 info using npm@3.10.10
3 info using node@v7.3.0
4 verbose run-script [ 'pretest', 'test', 'posttest' ]
5 info lifecycle bookshop@1.0.0~pretest: bookshop@1.0.0
6 silly lifecycle bookshop@1.0.0~pretest: no script for pretest, continuing
7 info lifecycle bookshop@1.0.0~test: bookshop@1.0.0
8 verbose lifecycle bookshop@1.0.0~test: unsafe-perm in lifecycle true
9 verbose lifecycle bookshop@1.0.0~test: PATH: /Users/marktyers/.nvm/versions/node/v7.3.0/lib/node_modules/npm/bin/node-gyp-bin:/Users/marktyers/Documents/bookshop/node_modules/.bin:/Users/marktyers/.nvm/versions/node/v7.3.0/bin:/Users/marktyers/google-cloud-sdk/bin:/Library/Frameworks/Python.framework/Versions/3.5/bin:/opt/local/bin:/opt/local/sbin:/Library/Frameworks/Python.framework/Versions/2.7/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Frameworks/Mono.framework/Versions/Current/Commands:/usr/local/mysql/bin:/usr/texbin
10 verbose lifecycle bookshop@1.0.0~test: CWD: /Users/marktyers/Documents/bookshop
11 silly lifecycle bookshop@1.0.0~test: Args: [ '-c', 'node --harmony-async-await jasmine.js' ]
12 silly lifecycle bookshop@1.0.0~test: Returned: code: 1  signal: null
13 info lifecycle bookshop@1.0.0~test: Failed to exec test script
14 verbose stack Error: bookshop@1.0.0 test: `node --harmony-async-await jasmine.js`
14 verbose stack Exit status 1
14 verbose stack     at EventEmitter.<anonymous> (/Users/marktyers/.nvm/versions/node/v7.3.0/lib/node_modules/npm/lib/utils/lifecycle.js:255:16)
14 verbose stack     at emitTwo (events.js:106:13)
14 verbose stack     at EventEmitter.emit (events.js:191:7)
14 verbose stack     at ChildProcess.<anonymous> (/Users/marktyers/.nvm/versions/node/v7.3.0/lib/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:191:7)
14 verbose stack     at maybeClose (internal/child_process.js:885:16)
14 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)
15 verbose pkgid bookshop@1.0.0
16 verbose cwd /Users/marktyers/Documents/bookshop
17 error Darwin 16.3.0
18 error argv "/Users/marktyers/.nvm/versions/node/v7.3.0/bin/node" "/Users/marktyers/.nvm/versions/node/v7.3.0/bin/npm" "run" "test"
19 error node v7.3.0
20 error npm  v3.10.10
21 error code ELIFECYCLE
22 error bookshop@1.0.0 test: `node --harmony-async-await jasmine.js`
22 error Exit status 1
23 error Failed at the bookshop@1.0.0 test script 'node --harmony-async-await jasmine.js'.
23 error Make sure you have the latest version of node.js and npm installed.
23 error If you do, this is most likely a problem with the bookshop package,
23 error not with npm itself.
23 error Tell the author that this fails on your system:
23 error     node --harmony-async-await jasmine.js
23 error You can get information on how to open an issue for this project with:
23 error     npm bugs bookshop
23 error Or if that isn't available, you can get their info via:
23 error     npm owner ls bookshop
23 error There is likely additional logging output above.
24 verbose exit [ 1, true ]

我很难理解为什么命令会产生不同的结果。

0 个答案:

没有答案