繁体   English   中英

npm中找不到nodemon怎么解决运行服务器时发生

[英]how to solve nodemon is not found in npm | occurred when run server

我有一个问题:nodemon 没有运行 npm 脚本(例如 npm 启动),但是如果在 npm 脚本之外的命令行上调用 nodemon,nodemon 运行正常。

$ nodemon server.js
11 Feb 22:59:51 - [nodemon] v1.3.7
11 Feb 22:59:51 - [nodemon] to restart at any time, enter `rs`
11 Feb 22:59:51 - [nodemon] watching: *.*
11 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

您可以通过在系统中全局安装 nodemon 来解决此问题。

npm install -g nodemon --save-dev

当 /node_modules/.bin 中不存在 nodemon 时,就会出现问题。

添加了 --save-dev ,因为它仅在开发过程中需要。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM