0

I'm following this guide, and I'm at the section were I need to run this code:

$ nodemon server

But I get this error:

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 server + ~~~~~~~ + CategoryInfo : ObjectNotFound: (nodemon:String) [], CommandNotFoundExce
ption + FullyQualifiedErrorId : CommandNotFoundException

I changed some settings in the package.json and installed npm globally but I'll try those again if needed.

Here is my server.js file:

const express = require('express');
const cors = require('cors');

require('dotenv').config();

const app = express();
const port = process.env.PORT || 5000;

app.use(cors());
app.use(express.json());

app.listen(port, () => {
    console.log(`Server is running on port: ${port}`);
});

I've installed nodemon fine previous to the error, I get this output when i installed nodemon.

PS C:\Users\username\mern-excercise-tracker\backend> npm install -g nodemon C:\Users\username\AppData\Roaming\npm\nodemon -> C:\Users\username\AppData\Roaming\npm\node_modules\nodemon\bin\nodemon.js

nodemon@1.19.3 postinstall C:\Users\username\AppData\Roaming\npm\node_modules\nodemon node bin/postinstall || exit 0

npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.9 (node_modules\nodemon\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.9: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})

  • nodemon@1.19.3 updated 1 package in 9.852s
nextlevel
  • 1
  • 3

1 Answers1

0

Look at this Answer this might give you more insight.

Other than that 1 workaround would be to use npx

npx nodemon server.js

You need npm@5.2.0 or greater. you can check your npm version by npm -v in CMD

Shivam
  • 3,514
  • 2
  • 13
  • 27