在 npm 中找不到 nodemon [英] nodemon not found in npm

查看:69
本文介绍了在 npm 中找不到 nodemon的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have a problem: nodemon does not run off the npm script (e.g. npm start),
but if nodemon is called on the command line outside the npm script, nodemon runs as normal.

$ 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 脚本中是如何调用的:

How it is called in npm script:

package.json

{
...
  "scripts": {
    "start": "nodemon server.js"
  }
}

运行 npm start 脚本时:

When npm start script is run:

$ 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

我一直在寻找解决方案,但没有找到.

I've been looking for a solution, but have not found one.

推荐答案

您可以通过将 nodemon 添加到您的 package.json 来解决此问题:

You can resolve this problem by adding nodemon to your package.json:

npm install nodemon --save-dev

/node_modules/.bin中不存在nodemon时会出现问题.

The problem happens when nodemon does not exist in /node_modules/.bin.

添加了 --save-dev 因为它只在开发过程中需要.

Added --save-dev since it's required during development only.

这篇关于在 npm 中找不到 nodemon的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆