0

So I started using nodemon a while ago and started to use it again recently. But I got an error from the VS-Code command line:

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

This basically means it isn't a command, similar thing would happen in an actual cmd.

Edit: I made this Q&A just for some people who have this same problem.

hexerous
  • 221
  • 1
  • 12
  • Does this answer your question? [What is the reason for "X is not recognized as an internal or external command, operable program or batch file"?](https://stackoverflow.com/questions/41454769/what-is-the-reason-for-x-is-not-recognized-as-an-internal-or-external-command) In this case PowerShell is used to to run the command line and not Windows command processor. But the reason for the error message output by `powershell.exe` instead of `cmd.exe` is the same: `nodemon` is either not installed or its folder path is not in any `PATH` or it has a file extension not listed in `PATHEXT`. – Mofi Sep 22 '20 at 05:30
  • I found out that this happens specifically for `nodemon` (via my friends on Discord). Not sure why but it happens. – hexerous Sep 22 '20 at 14:23
  • Open a [command prompt](https://www.howtogeek.com/235101/) and run `where nodemon`. If an error message is output as no `nodemon.*` can be found, run `dir %SystemDrive%\nodemon.* /A-D /B /S` to search in (nearly) entire system drive (usually `C:`) for a file with file name `nodemon`. If no file is found, there is no `nodemon` executable installed at all. Otherwise run `set path` and look on list of folder paths assigned to `PATH` and list of file extensions assigned to `PATHEXT`. Folder path of `nodemon.*` must be added to __user__ or __system__ `PATH` environment variable via Control Panel. – Mofi Sep 22 '20 at 14:39

1 Answers1

1

If you get this error, this probably means you either haven't installed nodemon, or it is not on your environment variable called 'Path'. I am assuming you did do npm install -g nodemon. Otherwise I have no idea what you are doing here. Also, this will be a very in-depth answer

So first, you want to go to your search bar in Windows. Then type; "env". 1

After, you want to click on "Edit the system environment variables". It's self-explanatory, it's the system environment's variables.

Then, you want to click on "Environment Variables." A window will pop up with a lot of things, you want to find the variable called 'Path' in the system variables:

1

You then want to select it and click "Edit". Then a tab will open up; with the contents of the variable, I am using version 10.0.18363 of Windows, yours might look different then mine. But you want to add a new variable. If you have this variable C:\Users\yourUsername\AppData\Roaming\npm and nodemon still doesn't work, you can skip this step. Otherwise you will see other paths listed, just append to it separating with semicolon.

For example, let's say the last path listed is, "C:\Windows\System32". I would add a ";", and then the path to nodemon, so the final result will look like: "C:\Windows\System32;C:\Users\dawoo\AppData\Roaming\npm".

After that, you want to click OK and then OK again. You should be fine now. If you still have the problem, like I did, you want to right-click on the Windows button, and click: "Windows PowerShell (Admin)". You want to copy and paste three things seperately. I pressed "A" for 1 and 2 (Yes to All), this might not work, so try "Yes", which is "Y".

  1. ) Set-ExecutionPolicy RemoteSigned

  2. ) Set-ExecutionPolicy Unrestricted

  3. ) Get-ExecutionPolicy

After you type Get-ExecutionPolicy, you should get "Unrestricted" or "RemoteSigned", something like that. Now, nodemon should work now! I just wanted to make this Q&A post because I saw lots of people DMing me on Discord saying nodemon doesn't work, and I also wanted to help others who stumbled across this problem. Have a great rest of your day.

Edit: OverFlow didn't save my changes, hopefully you see this but I found out how to fix this problem from one of my friends.

hexerous
  • 221
  • 1
  • 12