why Nodemon couldn't find the path to run its script

Viewed 124

I'm working on chat application , I'm using express , socket.io, moment and nodemon. if I run nodemon server.js it works, but if I want to run my script as follow npm run dev and this is inside my package.josn

 "dependencies": {
    "express": "^4.17.3",
    "moment": "^2.29.1",
    "nodemon": "^2.0.15",
    "socket.io": "^4.4.1"
  }


"scripts": {
    "dev" : "nodemon server.js"
  }

I'm getting this error :

'...\ChatApp-Rooms\node_modules\.bin\' 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 'C:\Users\Sam Taklimi\Desktop\nodemon\bin\nodemon.js'

for some reason the path of my nodemon is not correct ?! following stack overflow , in PowerShell I changed

ExecutionPolicy to 
Unrestricted

still doesn't work ?

1 Answers

You need to install nodemon as dependency of your project like that

npm i nodemon

When you run nodemon from your terminal you run a package that is probably installed globally. When you run it as part of your npm scripts you need to run it from the installed dependencies of your project

Related