package.json中定义的npm脚本会引发错误

时间:2016-10-22 09:08:58

标签: javascript node.js eslint package.json frisby.js

我已安装了eslint软件包,并向package.json添加了一系列脚本。

"scripts": {
    "start": "node index.js",
    "test": "node_modules/.bin/jasmine-node spec --color --verbose --autotest --watch .",
    "acceptance": "node_modules/.bin/forever stopall && node_modules/.bin/forever start index.js && ./node_modules/.bin/jasmine-node test/ --verbose && node_modules/.bin/forever stopall",
    "coverage": "./node_modules/.bin/istanbul cover -x **spec/** -x **index.js** -x **debug.js** jasmine-node spec",
    "doc": "node_modules/.bin/jsdoc modules/",
    "linter": "node_modules/.bin/eslint ."
}

运行这些脚本时,我遇到了不同的成功。 npm run testnom run coveragenom run doc都运行没有错误但是npm run acceptancenpm run linter运行脚本然后抛出一系列错误,(我复制了linter示例)下文)。

npm ERR! Darwin 16.0.0
npm ERR! argv "/Users/user/.nvm/versions/node/v6.7.0/bin/node"
"/Users/user/.nvm/versions/node/v6.7.0/bin/npm" "run" "linter"
npm ERR! node v6.7.0
npm ERR! npm  v3.10.3
npm ERR! code ELIFECYCLE
npm ERR! todo@1.0.0 linter: `eslint .`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the todo@1.0.0 linter script 'eslint .'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the todo package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     eslint .
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs todo
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls todo
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /Users/user/Documents/todo/npm-debug.log

验收测试甚至无法在运行前启动脚本。为什么我会收到这些错误? npm-debug.log的内容是:

0 info it worked if it ends with ok
1 verbose cli [ '/Users/user/.nvm/versions/node/v6.7.0/bin/node',
1 verbose cli   '/Users/user/.nvm/versions/node/v6.7.0/bin/npm',
1 verbose cli   'run',
1 verbose cli   'linter' ]
2 info using npm@3.10.3
3 info using node@v6.7.0
4 verbose run-script [ 'prelinter', 'linter', 'postlinter' ]
5 info lifecycle todo@1.0.0~prelinter: todo@1.0.0
6 silly lifecycle todo@1.0.0~prelinter: no script for prelinter, continuing
7 info lifecycle todo@1.0.0~linter: todo@1.0.0
8 verbose lifecycle todo@1.0.0~linter: unsafe-perm in lifecycle true
9 verbose lifecycle todo@1.0.0~linter: PATH: /Users/user/.nvm/versions/node/v6.7.0/lib/node_modules/npm/bin/node-gyp-bin:/Users/user/Documents/todo/node_modules/.bin:/Users/user/.nvm/versions/node/v6.7.0/bin:/Users/user/google-cloud-sdk/bin:/Library/Frameworks/Python.framework/Versions/3.5/bin:/Users/user/.nvm/versions/node/v6.7.0/bin:/opt/local/bin:/opt/local/sbin:/Library/Frameworks/Python.framework/Versions/2.7/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/mysql/bin:/usr/texbin
10 verbose lifecycle todo@1.0.0~linter: CWD: /Users/user/Documents/todo
11 silly lifecycle todo@1.0.0~linter: Args: [ '-c', 'eslint .' ]
12 silly lifecycle todo@1.0.0~linter: Returned: code: 1  signal: null
13 info lifecycle todo@1.0.0~linter: Failed to exec linter script
14 verbose stack Error: todo@1.0.0 linter: `eslint .`
14 verbose stack Exit status 1
14 verbose stack     at EventEmitter.<anonymous> (/Users/user/.nvm/versions/node/v6.7.0/lib/node_modules/npm/lib/utils/lifecycle.js:242: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/user/.nvm/versions/node/v6.7.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:877:16)
14 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)
15 verbose pkgid todo@1.0.0
16 verbose cwd /Users/user/Documents/todo
17 error Darwin 16.0.0
18 error argv "/Users/user/.nvm/versions/node/v6.7.0/bin/node" "/Users/user/.nvm/versions/node/v6.7.0/bin/npm" "run" "linter"
19 error node v6.7.0
20 error npm  v3.10.3
21 error code ELIFECYCLE
22 error todo@1.0.0 linter: `eslint .`
22 error Exit status 1
23 error Failed at the todo@1.0.0 linter script 'eslint .'.
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 todo package,
23 error not with npm itself.
23 error Tell the author that this fails on your system:
23 error     eslint .
23 error You can get information on how to open an issue for this project with:
23 error     npm bugs todo
23 error Or if that isn't available, you can get their info via:
23 error     npm owner ls todo
23 error There is likely additional logging output above.
24 verbose exit [ 1, true ]

0 个答案:

没有答案