4

I successfully installed nodemon on my local machin, however it is giving me below error message when I run the code.

here is the error detail

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 
1
  • 1
    Have you correctly installed the module with the -g flag, and set up the path environment variable ? Edit: you can also use the command throught NPM. Just create a script with your command inside your package.json and call your script with npm run scriptName, and the module executable will be "fetched" from the node_modules folder. Commented Jul 4, 2018 at 13:37

10 Answers 10

6

I had the same problem,simple fix first check if path exists on your Environment variable path or not

To check

Control panel>System>Advanced System Settings>Environment Variables>double-click on PATH

Now check if you have this PATH C:\Users\yourUsername\AppData\Roaming\npm

If not, you will see some existing paths, just append to it separating with semicolon. That's it! Worked for me.

add PATH C:\Users\yourUsername\AppData\Roaming\npm in Environment Variables path

Sign up to request clarification or add additional context in comments.

Comments

5

Try this for Windows

Open PowerShell and enter the following commands.

A)Set-ExecutionPolicy RemoteSigned

B)Set-ExecutionPolicy Unrestricted

C)Get-ExecutionPolicy

D)Exit

1 Comment

This worked perfectly for me. Just had to run powershell as admin. My error, however, was a security error. PSSecurityException: UnauthorizedAccess
4

This works for me: this should limit the policy to the current user.

Set-ExecutionPolicy RemoteSigned -Scope CurrentUser

Comments

4

i found a way around it , just go inside package.json ( the file that was created after u typed npm init ) and under "scripts" just put start: "nodemon <filename>" and now everytime u type npm start in ur terminal nodemon should start with ur file

Comments

3

I encountered this problem too.

I installed nodemon in a local directory and tried to run nodemon index.js

then I got the above error

I ran npx nodemon index.js and the server started successfully

2 Comments

This does not really answer the question. If you have a different question, you can ask it by clicking Ask Question. To get notified when this question gets new answers, you can follow this question. Once you have enough reputation, you can also add a bounty to draw more attention to this question. - From Review
This solves my problem but WHY?
2

I installed nodemon globally and it's started works:

npm install -g nodemon 

Comments

1

I had the same problem and nothing worked. Finally after spending hours found the solution.

If you are using Windows, follow these steps=>

If you're using powershell, then

Open PowerShell and enter the following lines.

  1. Set-ExecutionPolicy RemoteSigned

  2. Set-ExecutionPolicy Unrestricted

  3. Get-ExecutionPolicy

  4. Exit

If you're using command prompt, then

On start menu, search "cmd" , and then right click and run as administrator. Now you'll have the administrator command prompt running.

Type these instructions =>

1)PowerShell Set-ExecutionPolicy RemoteSigned

2)PowerShell Set-ExecutionPolicy Unrestricted

3)PowerShell Get-ExecutionPolicy

4)PowerShell Exit

Now Try nodemon [your node app] Now that your nodemon should be working fine. Also make sure you have globally installed nodemon npm install -g nodemon. Thanks!

Comments

0

Here are some steps for a windows user:

Open PowerShell and enter:

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

Might be that it still doesn't work in your IDE. If it happens just close and re-open your IDE and try to run it again.

Another option can be that you have to go to your terminal (windows + r) and run:

npm install -g nodemon 

Those three steps should solve the problem in any case.

1 Comment

Those steps are not working either
0

In cmd type npx nodemon server.js and then it will start...

For example,
[nodemon] 2.0.15
[nodemon] to restart at any time, enter rs
[nodemon] watching path(s): .
[nodemon] watching extensions: js,mjs,json
[nodemon] starting node server.js

Comments

0

This was giving me issues as well on Windows 10. My solution that worked:

  1. run:

npm i nodemon --save-dev

  1. In package.json add this (main is whatever file you need to watch):

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

  1. run:

npm run watch

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.