I've installed nodemon using npm i -g nodemon and this was installed in the global path which is:
C:\Users\John\AppData\Roaming
so I started a new project using npm i -y and created a simple index.js entry point using:
{
"name": "scp",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "node index.js"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"express": "^4.17.1",
"jsonwebtoken": "^8.5.1"
}
}
when I start the app using nodemon I got:
Error: Cannot find module 'C:\Program Files\nodejs\node_modules\nodemon\bin\nodemon.js'
as you can see the path is actually wrong, so I tried to change it using:
npm config set prefix C:\Users\John\AppData\Roaming
npm config get prefix
and this return:
C:\Users\John\AppData\Roaming
the problem's that when I start the app using nodemon I get the same error message 'cause the path is always wrong:
Error: Cannot find module 'C:\Program Files\nodejs\node_modules\nodemon\bin\nodemon.js'
how can I fix this?