I am a beginner in NodeJS
Environment is Windows 11 64 Bit.
Node and Nodemon (Globally too) and NPM are installed and working.
Now when I run the command
npm run server
It gives the following error
> devconnector@1.0.0 server
> nodemon server
'MongoDB' is not recognized as an internal or external command,
operable program or batch file.
node:internal/modules/cjs/loader:936
throw err;
^
Error: Cannot find module 'D:\Education\nodemon\bin\nodemon.js'
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
at Function.Module._load (node:internal/modules/cjs/loader:778:27)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12)
at node:internal/main/run_main_module:17:47 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}
Its looking in the wrong folder for the nodemon files. When I pasted the files there it worked fine but I want to change the folder it searches for those files in.
Here is my server.js file
const express = require("express");
const app = express();
app.get("/", (req, res) => res.send("API Running"));
const PORT = process.env.PORT || 5000;
app.listen(PORT, () => console.log(`Server started on port ${PORT}`));
And my package.json file
{
"name": "devconnector",
"version": "1.0.0",
"description": "Social network for developers",
"main": "server.js",
"scripts": {
"start": "node server",
"server": "nodemon server"
},
"author": "Sanket Pagadpalliwar",
"license": "MIT",
"dependencies": {
"bcryptjs": "^2.4.3",
"config": "^3.3.7",
"dotenv": "^16.0.0",
"express": "^4.17.3",
"express-validator": "^6.14.0",
"gravatar": "^1.8.2",
"jsonwebtoken": "^8.5.1",
"mongoose": "^6.2.9",
"request": "^2.88.2"
},
"devDependencies": {
"concurrently": "^7.0.0",
"nodemon": "^2.0.15"
}
}
Most likely the file in the specified D:\Education\nodemon\bin\nodemon.js field in your nodemon module may be missing or corrupt. Have you checked the file? If there is no problem with the file, try reinstalling it the way you installed it, this will most likely solve the problem.
Have a nice day