aku*_*kul 67 node.js npm nodemon
我有一个问题: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`
Run Code Online (Sandbox Code Playgroud)
如何在npm脚本中调用它:
package.json
{
...
"scripts": {
"start": "nodemon server.js"
}
}
Run Code Online (Sandbox Code Playgroud)
当运行npm start脚本时:
$ 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
Run Code Online (Sandbox Code Playgroud)
我一直在寻找解决方案,但还没有找到解决方案.
sia*_*olt 102
您可以通过将nodemon添加到package.json来解决此问题
npm install nodemon --save-dev
Run Code Online (Sandbox Code Playgroud)
在/node_modules/.bin中不存在nodemon时会发生此问题
gre*_*y87 36
尝试检查已安装的全局包npm list -g --depth=0.如果你找不到nodemon, - 用旗帜-g或安装它--save-dev.不要nodemon用flag 安装--save,因为nodemon只用于development.
小智 28
在您当前的项目目录下,运行
npm install nodemon --save //save in package.json so that the following code cam find your nodemon
Run Code Online (Sandbox Code Playgroud)
然后在你的package.json文件中的"scripts"下添加"start":"nodemon app.js"(或者你的入口点是什么)
所以看起来像这样:
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "nodemon app.js"
}
Run Code Online (Sandbox Code Playgroud)
然后跑
npm start
Run Code Online (Sandbox Code Playgroud)
这避免了复杂的PATH设置,它适用于我的mac
希望可以帮助你;)
Nil*_*war 24
nodemon使用以下命令全局安装.它可以在我的电脑上运行,我相信它也适用于你的系统.
npm install nodemon -g --save
Run Code Online (Sandbox Code Playgroud)
有时您应该有权在全球范围内安装它.可以使用以下命令轻松完成.
在LINUX UBUNTU中:
sudo npm install nodemon -g --save
在Fedora中:
a)su
b)npm install nodemon -g --save
当我使用:安装nodemon npm install nodemon -g --save时,PATH变量中没有全局npm包的路径.
如果你只是将它添加到$ PATH变量,它将得到修复.
编辑~/.bashrc主文件夹中的文件并添加以下行: -
export PATH=$PATH:~/npm
Run Code Online (Sandbox Code Playgroud)
这里"npm"是我的全局npm包的路径.将其替换为系统中的全局路径
| 归档时间: |
|
| 查看次数: |
94345 次 |
| 最近记录: |