0

I've installed nodemon globally many times but when I try and run it, it doesn't work. This is the error I'm getting:

nodemon : The term 'nodemon' is not recognized as the name of a cmdlet, 
or if a path was included, verify that the path is correct and try again.    
At line:1 char:1
+ nodemon server.js
+ ~~~~~~~
    + CategoryInfo          : ObjectNotFound: (nodemon:String) [], CommandN  
   otFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

I don't understand why I can't use nodemon when I've installed it globally. I get this error in my VSCode terminal but in my cmd.exe, I get this error:

'nodemon' is not recognized as an internal or external command,
operable program or batch file.

I've tried installing it globally from both the terminal and command prompt. I've also tried deleting node_modules and package-lock.json, and reinstalling them by doing npm install. I don't understand why this is happening and don't know what to do.

Soccerball123
  • 741
  • 5
  • 17
  • seems that your path might be messed up.. Try `C:\>npm config get prefix` - copy the output and paste it as new environmental var inside your advanced settings (when on WIN).. then run it and see ifit works.. – iLuvLogix Jul 14 '22 at 13:37
  • Do I do it as a system variable or User variable? EDIT: I did it and it's still not working – Soccerball123 Jul 14 '22 at 13:52
  • As you like - do you want it system-wide or for a specific user? -> pls see answer here https://stackoverflow.com/questions/40359590/nodemon-command-is-not-recognized-in-terminal-for-node-js-server – iLuvLogix Jul 14 '22 at 13:53

2 Answers2

1

Use npx nodemon, your environment variables of your OS are probably broken and don't link to where npm global packages get installed.

Scar
  • 355
  • 2
  • 8
  • How can I fix my environmental variable? In the "User variables" portion I added a new "path" variable and linked it to the output of `npm config get prefix` of my machine. I also added that output to the path in my system variables. Did I do something wrong here? – Soccerball123 Jul 14 '22 at 13:56
  • https://stackoverflow.com/questions/27864040/fixing-npm-path-in-windows-8-and-10 – Scar Jul 14 '22 at 14:00
0

your npm that module does not support or is not compatible with Nodemon so try to use

npx

instead of

npm