【发布时间】:2015-04-26 10:15:48
【问题描述】:
我第一次将 npm 模块添加到我的项目中(jshint、optimg、jpgo)。我注意到一些项目,当我执行 npm run [name] 时,会给出“sh: [name]: command not found”的结果。
我无法弄清楚为什么这些不起作用,但其他 npm 安装可以。所有这些都安装在本地;我可以通过查看项目根目录中的 /node_modules 文件夹来查看安装,并使用 npm ls.
进行验证出现此错误的最新软件包是 html-minify。我的 package.json 看起来像这样(并在 http://jsonlint.com/ 验证):
{
"name": "npmTest",
"devDependencies": {
"jshint": "latest",
"optimg": "latest",
"jpgo": "latest",
"ycssmin": "latest",
"html-minify": "latest"
},
"scripts": {
"lint": "jshint **.js",
"png": "optimg",
"jpg": "jpgo",
"css": "ycssmin **.css",
"html": "html-minify"
}
}
我尝试了“html-minify **.html”,但结果是“未找到”错误。
为什么我会得到“sh: [npm package name]: command not found”? 我已经阅读了其他线程,并且因为其他模块工作,我怀疑我需要添加我的 PATH 中的任何内容,或启动服务器,或全局安装。
更完整的错误消息(用于 html5-lint):
$ npm run html
> npmTest@ html /Users/Steve/Documents/APPS/Test_Apps/npmTest
> html5-lint
sh: html5-lint: command not found
npm ERR! npmTest@ html: `html5-lint`
npm ERR! Exit status 127
npm ERR!
npm ERR! Failed at the npmTest@ html script.
npm ERR! This is most likely a problem with the npmTest package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! html5-lint
npm ERR! You can get their info via:
npm ERR! npm owner ls npmTest
npm ERR! There is likely additional logging output above.
npm ERR! System Darwin 14.1.0
npm ERR! command "node" "/usr/local/bin/npm" "run" "html"
npm ERR! cwd /Users/Steve/Documents/APPS/Test_Apps/npmTest
npm ERR! node -v v0.10.25
npm ERR! npm -v 1.3.24
npm ERR! code ELIFECYCLE
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /Users/Steve/Documents/APPS/Test_Apps/npmTest/npm-debug.log
npm ERR! not ok code 0
【问题讨论】:
-
Ubuntu 14.04.5 LTS(GNU/Linux 3.13.0-110-generic x86_64),节点 6.10.0,npm 3.10.10。同样的问题。
标签: npm