我有一个问题:nodemon没有运行npm脚本(例如npm start),

$ 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

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

推荐答案

您可以通过在package.json中添加nodemon来解决此问题:

npm install nodemon --save-dev

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

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

Node.js相关问答推荐

Node js 处理回调和 Promise

无法将示例 Node.js 应用程序部署到 AWS Elastic Beanstalk

将 null 推入管道后,node.js 可写完成未发出

我如何在 Raku 的供应中注册不同的事件?

我正在try 在公共目录中使用 Express.js 项目部署 Angular 静态构建

将文件传递到 AWS lambdas(nodejs) + API 网关后重新上传文件

我应该转译我的 TypeScript 应用程序吗?

当我try 从本地主机发布新产品时收到错误消息

在mongodb中只查询整数

从数据库读取数据并将其作为可下载的 zip 文件发送

NodeJs 过滤掉目录异步

使用restify时如何支持cors

使用 Webpack 和 font-face 加载字体

为什么我们要为 Angular 2.0 安装 Node.js?

Mongoose - 保存字符串数组

当进程被杀死时,如何优雅地关闭我的 Express 服务器?

Javascript在try块内设置const变量

如何让 Mocha 加载定义全局挂钩或实用程序的 helper.js 文件?

如何设置 useMongoClient (Mongoose 4.11.0)?

Node.js 中的 Streams3 是什么,它与 Streams2 有何不同?