Node.js 命令行上的cmd工作时npm运行cmd失败

Node.js 命令行上的cmd工作时npm运行cmd失败,node.js,npm,jshint,exit-code,Node.js,Npm,Jshint,Exit Code,在我的发言中: 如果我运行node\u modules/.bin/jshint.我会得到: $ node_modules/.bin/jshint . test/inAdapters_fileAdapter.js: line 73, col 31, Missing semicolon. 1 error 它正确执行并产生预期的输出:1错误 但是,如果我将该命令添加到package.json中,并尝试通过npm run运行它,那么它会工作并产生预期的输出,但也会随之产生一系列错误: $ npm r

在我的发言中:

如果我运行
node\u modules/.bin/jshint.
我会得到:

$ node_modules/.bin/jshint .
test/inAdapters_fileAdapter.js: line 73, col 31, Missing semicolon.

1 error
它正确执行并产生预期的输出:1错误

但是,如果我将该命令添加到package.json中,并尝试通过
npm run
运行它,那么它会工作并产生预期的输出,但也会随之产生一系列错误:

$ npm run jshint

> http-status-check@0.0.5 jshint /home/guy/source/http-status-check
> jshint .

test/inAdapters_fileAdapter.js: line 73, col 31, Missing semicolon.

1 error

npm ERR! Linux 3.13.0-24-generic
npm ERR! argv "node" "/home/guy/local/bin/npm" "run" "jshint"
npm ERR! node v0.10.31
npm ERR! npm  v2.0.0
npm ERR! code ELIFECYCLE
npm ERR! http-status-check@0.0.5 jshint: `jshint .`
npm ERR! Exit status 2
npm ERR! 
npm ERR! Failed at the http-status-check@0.0.5 jshint script.
npm ERR! This is most likely a problem with the http-status-check package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     jshint .
npm ERR! You can get their info via:
npm ERR!     npm owner ls http-status-check
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /home/guy/source/http-status-check/npm-debug.log
在package.json中是这样定义的:

  "scripts": {
    "jshint": "node_modules/.bin/jshint .",
  },
我做错了什么

除非你是认真的,否则不要带着非零错误代码退出。除卸载脚本外,这将导致npm操作失败,并可能回滚。如果故障很小或仅会阻止某些可选功能,则最好只打印一条警告并成功退出

使用:


或者编写一个调用jshint的包装器,然后忽略退出代码并成功退出,退出代码为零。

如果运行
npmJShint
?@RodrigoMedeiros-它为您提供了npm的帮助语法-与运行
npm--help
一样,这正是我需要的。有人能解释为什么这是必要的吗?我来这里是为了寻找解决这个问题的方法,希望尽可能避免强制返回true。有人有Windows兼容的答案吗?
node_modules/.bin/jshint .; true