nodemon 在 Windows 10 中无法工作

问题描述 投票:0回答:11

我在本地计算机上成功安装了nodemon,但是当我运行代码时,它给出了以下错误消息。

这是错误详细信息

The term 'nodemon' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was
included, verify that the path is correct and try again.
At line:1 char:1
+ nodemon
+ ~~~~~~~
    + CategoryInfo          : ObjectNotFound: (nodemon:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException
node.js nodemon
11个回答
6
投票

我遇到了同样的问题,简单修复首先检查环境变量路径中是否存在路径

检查

控制面板>系统>高级系统设置>环境变量>双击PATH

现在检查您是否有此路径C:\Users\yourUsername\AppData\Roaming 下午

如果没有,您将看到一些现有路径,只需追加到其中并用分号分隔即可。就是这样!为我工作。

添加路径C:\Users\yourUsername\AppData\Roaming pm 在环境变量路径


5
投票

在 Windows 上试试这个

打开 PowerShell 并输入以下命令。

A)

Set-ExecutionPolicy RemoteSigned

B)

Set-ExecutionPolicy Unrestricted

C)

Get-ExecutionPolicy

D)

Exit


4
投票

这对我有用:这应该将策略限制为当前用户。

Set-ExecutionPolicy RemoteSigned -Scope CurrentUser


4
投票

我找到了解决方法,只需进入 package.json (在您输入 npm init 后创建的文件)并在“脚本”下输入

start: "nodemon <filename>" 
,现在每次您在终端中输入 npm start 时,nodemon 都应该以你的文件


2
投票

我全局安装了nodemon并且它开始工作了:

npm install -g nodemon

2
投票

我也遇到这个问题了

我在本地目录中安装了nodemon并尝试运行

nodemon index.js

然后我得到了上面的错误

我运行了

npx nodemon index.js
,服务器启动成功了


1
投票

我也遇到了同样的问题,但没有任何效果。花了几个小时终于找到了解决方案。

如果您使用的是 Windows,请按照以下步骤操作=>

如果您使用的是 powershell,那么

打开 PowerShell 并输入以下行。

  1. 设置执行策略远程签名

  2. 设置执行策略不受限制

  3. 获取执行策略

  4. 退出

如果您使用命令提示符,那么

在开始菜单中搜索“cmd”,然后右键以管理员身份运行。 现在您将运行管理员命令提示符。

输入这些说明=>

1)PowerShell 设置执行策略 RemoteSigned

2)PowerShell 设置-执行策略不受限制

3)PowerShell 获取执行策略

4)PowerShell 退出

现在尝试nodemon [你的节点应用程序] 现在您的nodemon 应该可以正常工作了。 还要确保你已经全局安装了nodemon npm install -g nodemon。 谢谢!


0
投票

以下是针对 Windows 用户的一些步骤:

打开PowerShell并输入:

Set-ExecutionPolicy RemoteSigned (yes)
Set-ExecutionPolicy Unrestricted (yes)
Get-ExecutionPolicy
Exit

可能它仍然无法在您的 IDE 中运行。如果发生这种情况,只需关闭并重新打开 IDE,然后尝试再次运行它。

另一种选择是您必须转到终端 (windows + r) 并运行:

npm install -g nodemon

这三个步骤应该可以解决任何情况下的问题。


0
投票

在 cmd 中输入 npx nodemon server.js 然后它将启动...

例如,
[nodemon] 2.0.15
[nodemon] 随时重启,输入

rs

[nodemon] 观察路径:.
[nodemon] 观看扩展:js、mjs、json
[nodemon] 开始
node server.js


0
投票

这在 Windows 10 上也给我带来了问题。 我的解决方案有效:

  1. 运行:

npm 我的nodemon --save-dev

  1. 在 package.json 添加此内容(main 是您需要观看的任何文件):

“main”:“app.js”,
"scripts":{"watch": "nodemon ./app.js"}

  1. 运行:

npm 运行手表


0
投票

nodemon 修复说明

[

the " fix fixInstructions " detailed below are crafted for the windows 10 operating system

[
    fixInstructions

    [
        install nodemon globally 

            [

                npm install -g nodemon

            ]

        get prefix

            [

                npm config get prefix

            ]

            you will get an output such as

            [

                C:\Users\nq816hu\AppData\Roaming\npm

            ]

            copy the output
        
        navigate to settings and set variables

            [

                to the settings

                    [

                        on your keyboard

                        [

                            press " windows key + I " 

                        ]

                        [

                            this will open settings

                        ]

                        click on system

                            [

                                this will open a dashboard with a scrollable menu on the left

                            ]
                    
                        scroll the left side menu to find & click the about option at the bottom 

                            [

                                this will open the about settings

                            ]

                        under about settings scroll to the bottom & under related settings click on advanced system settings

                            [

                                this will pop out a small window with the name system properties

                            ]
                    
                        on the bottom of the small window just before the okay cancel & apply options click on environment variables

                            [

                                this will pop another slightly bigger window with the title environment variables 

                            ]

                    ]

            ]

            to set the variables

                [

                    the window contains two types of settings on top the user variables and bottom system variables

                    on user variables click on new

                        [

                            this will pop a small window with the title new user variable with two input fields namely variable name & variable value

                        ]
                    
                    to set the values 

                        [

                            variable name = path

                                [
                                    note

                                        [

                                            use the word " path "

                                        ]
                                ]

                            variable path = C:\Users\nq816hu\AppData\Roaming\npm

                                [

                                    note

                                    [

                                    the " variable value " should be the result you get after running the command below as stated above

                                        [

                                            npm config get prefix

                                        ]

                                    ]

                                ]

                        ]

                ]

        now run nodemon

        [

            C:\Users\nq816hu>nodemon

        ]

        troubleshooting

        [

            if the above fix failed there are several things you should check 

            [

                1

                    [

                        are you using the windows 10 version of windows

                            [

                                note 

                                    [

                                        these instructions have been crafted for windows specifically windows 10

                                            [
                                                
                                                however

                                                    [

                                                        if you are using an older or newer version of windows the way to navigate to the system properties window could be different you can google for more instructions

                                                    ]

                                            ]

                                    ]

                            ]

                    ]
                
                2 

                    [

                        have you installed npm

                            [

                                note

                                [

                                    npm comes with nodejs you may want to download and install nodejs first

                                ]
                            ]

                    ]

            ]

            if no solution was found 

                [

                    consider asking for help from someone with experience

                        [

                            sorry

                                [

                                    apologies for your struggle

                                ]

                        ]

                ]

        ]

    ]

]

]

© www.soinside.com 2019 - 2024. All rights reserved.