bash 找不到 nodemon 命令

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/45697551/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-18 16:22:21  来源:igfitidea点击:

nodemon command not found

node.jsbashnpmnodemon

提问by Christoffer Corfield Aakre

When i input "nodemon", i get the following error: "bash: nodemon: command not found". I've tried installing it both locally and globally, and it actuall worked yesterday, and I can't remember what I've changed so that it doesn't work anymore. I am using the Git Bash shell.

当我输入“nodemon”时,出现以下错误:“bash: nodemon: command not found”。我已经尝试在本地和全球范围内安装它,它昨天确实有效,我不记得我做了什么改变,所以它不再工作了。我正在使用 Git Bash shell。

When i install nodemon, i get the following output:

当我安装 nodemon 时,我得到以下输出:

$ npm install nodemon --save
[email protected] C:\users\corfi\Google Drive\coding\webdev\site
`-- [email protected]
  +-- [email protected]
  | +-- [email protected]
  | | +-- [email protected]
  | | | +-- [email protected]
  | | | | `-- [email protected]
  | | | +-- [email protected]
  | | | +-- [email protected]
  | | | | +-- [email protected]
  | | | | | `-- [email protected]
  | | | | |   +-- [email protected]
  | | | | |   +-- [email protected]
  | | | | |   `-- [email protected]
  | | | | |     +-- [email protected]
  | | | | |     | `-- [email protected]
  | | | | |     `-- [email protected]
  | | | | +-- [email protected]
  | | | | `-- [email protected]
  | | | +-- [email protected]
  | | | | `-- [email protected]
  | | | +-- [email protected]
  | | | +-- [email protected]
  | | | +-- [email protected]
  | | | | +-- [email protected]
  | | | | | `-- [email protected]
  | | | | `-- [email protected]
  | | | +-- [email protected]
  | | | | +-- [email protected]
  | | | | `-- [email protected]
  | | | `-- [email protected]
  | | |   +-- [email protected]
  | | |   `-- [email protected]
  | | `-- [email protected]
  | |   `-- [email protected]
  | +-- [email protected]
  | +-- [email protected]
  | +-- [email protected]
  | | `-- [email protected]
  | +-- [email protected]
  | | `-- [email protected]
  | `-- [email protected]
  |   `-- [email protected]
  +-- [email protected]
  +-- [email protected]
  | +-- [email protected]
  | | +-- [email protected]
  | | | `-- [email protected]
  | | +-- [email protected]
  | | | +-- [email protected]
  | | | `-- [email protected]
  | | `-- [email protected]
  | |   +-- [email protected]
  | |   +-- [email protected]
  | |   `-- [email protected]
  | `-- [email protected]
  +-- [email protected]
  | `-- [email protected]
  |   +-- [email protected]
  |   +-- [email protected]
  |   +-- [email protected]
  |   +-- [email protected]
  |   +-- [email protected]
  |   +-- [email protected]
  |   `-- [email protected]
  +-- [email protected]
  | `-- [email protected]
  |   `-- [email protected]
  +-- [email protected]
  `-- [email protected]
    +-- [email protected]
    | +-- [email protected]
    | +-- [email protected]
    | +-- [email protected]
    | | `-- [email protected]
    | +-- [email protected]
    | `-- [email protected]
    +-- [email protected]
    | +-- [email protected]
    | | `-- [email protected]
    | +-- [email protected]
    | +-- [email protected]
    | +-- [email protected]
    | | `-- [email protected]
    | +-- [email protected]
    | +-- [email protected]
    | | +-- [email protected]
    | | `-- [email protected]
    | `-- [email protected]
    +-- [email protected]
    +-- [email protected]
    | `-- [email protected]
    |   +-- [email protected]
    |   | +-- [email protected]
    |   | | +-- [email protected]
    |   | | `-- [email protected]
    |   | +-- [email protected]
    |   | +-- [email protected]
    |   | +-- [email protected]
    |   | +-- [email protected]
    |   | +-- [email protected]
    |   | +-- [email protected]
    |   | +-- [email protected]
    |   | +-- [email protected]
    |   | | `-- [email protected]
    |   | |   `-- [email protected]
    |   | `-- [email protected]
    |   `-- [email protected]
    |     `-- [email protected]
    |       +-- [email protected]
    |       +-- [email protected]
    |       +-- [email protected]
    |       `-- [email protected]
    +-- [email protected]
    | `-- [email protected]
    |   `-- [email protected]
    +-- [email protected]
    `-- [email protected]

npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.0.0 (node_modules\chokidar\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm WARN [email protected] No repository field.

回答by Andre Carneiro

Try to install nodemon globally

尝试全局安装 nodemon

npm install -g nodemon

Windows sometimes looses references in environment. If you′re using Windows 10, try to find nodemon.js in "C:\Users\YOUR_USER\AppData\Roaming\npm\node_modules\nodemon\bin". Then copy this path and execute

Windows 有时会丢失环境中的引用。如果您使用的是 Windows 10,请尝试在“C:\Users\YOUR_USER\AppData\Roaming\npm\node_modules\nodemon\bin”中找到 nodemon.js。然后复制这个路径并执行

node THE_PATH\nodemon.js YOUR_COOL_APP.js

It′s a workaround, but it usually works. Hope it helps...

这是一种解决方法,但通常有效。希望能帮助到你...

回答by Link0352

go to the directory you want to use nodemon, then use the path to where nodemon is installed in your node modules instead of just nodemon. i.e.

转到要使用 nodemon 的目录,然后使用 nodemon 安装在 node 模块中的路径,而不仅仅是 nodemon。IE

c:/user/[your path here]/nodemon [your node app] 

instead of

代替

nodemon [your node app]

回答by Anish Mathew

Actually we have to find out the location where nodemon is installed and then add its path in path variable.

实际上我们必须找出nodemon的安装位置,然后将其路径添加到path变量中。

C:\ >npm config get prefix

C:\Users\username\AppData\Roaming\npm

C:\ >set PATH=%PATH%;C:\Users\username\AppData\Roaming\npm;

C:\ > npm config 获取前缀

C:\用户\用户名\AppData\Roaming\npm

C:\>set PATH=%PATH%;C:\Users\username\AppData\Roaming\npm;

You have to run this on command prompt.

您必须在命令提示符下运行它。