我有一个问题: nodemon不能运行npm脚本(例如npm start
),
但是,如果在npm脚本之外的命令行上调用nodemon,nodemon将正常运行。
$ nodemon server.js
14 Feb 22:59:51 - [nodemon] v1.3.7
14 Feb 22:59:51 - [nodemon] to restart at any time, enter `rs`
14 Feb 22:59:51 - [nodemon] watching: *.*
14 Feb 22:59:51 - [nodemon] starting `node server.js`
在npm脚本中的调用方式:
package.json
{
...
"scripts": {
"start": "nodemon server.js"
}
}
运行npm启动脚本时:
$ npm start
> aaa@0.0.1 start /home/akul/Documents/aaa
> nodemon server.js
sh: 1: nodemon: not found
npm ERR! Linux 3.13.0-45-generic
npm ERR! argv "node" "/home/akul/npm-global/bin/npm" "start"
npm ERR! node v0.12.0
npm ERR! npm v2.5.0
npm ERR! code ELIFECYCLE
npm ERR! aaa@0.0.1 start: `nodemon server.js`
npm ERR! Exit status 127
npm ERR!
npm ERR! Failed at the aaa@0.0.1 start script 'nodemon server.js'.
npm ERR! This is most likely a problem with the aaa package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! nodemon server.js
npm ERR! You can get their info via:
npm ERR! npm owner ls aaa
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /home/akul/Documents/aaa/npm-debug.log
我一直在寻找解决方案,但还没有找到。
发布于 2015-02-15 00:22:04
您可以通过向package.json
中添加nodemon
来解决此问题
npm install nodemon --save-dev
当/node_modules/.bin
中不存在nodemon
时,就会出现问题。
添加了--save-dev
,因为它只在开发期间是必需的。
发布于 2016-09-15 18:13:46
尝试检查已安装的全局包npm list -g --depth=0
。如果找不到nodemon
,请使用-g
或--save-dev
标志安装它。不要安装带有--save
标志的nodemon
,因为nodemon
只用于development
。
发布于 2018-12-31 13:35:04
尝试全局安装nodemon。
sudo npm install -g nodemon
https://stackoverflow.com/questions/28517494
复制相似问题