最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Unable to install npm nodemon - Stack Overflow

programmeradmin4浏览0评论

I am trying to install npm package nodemon by running this command: npm i nodemon -g

And I am receiving this error message below:

npm error code MODULE_NOT_FOUND
npm error path \?\C:\Program Files\nodejs\node_modules\npm\node_modules\tuf-js\node_modules\make-fetch-happen\package.json
npm error Cannot find module 'C:\Program Files\nodejs\node_modules\npm\node_modules\tuf-js\node_modules\make-fetch-happen\lib\index.js'. Please verify that the package.json has a valid "main" entry
npm error A complete log of this run can be found in: C:\Users\mbulelo.tshabane\AppData\Local\npm-cache_logs\2025-03-06T14_33_24_047Z-debug-0.log

I have tried the following command as well below:

npm install nodemon --save-dev

Still same error message received.

I am trying to install npm package nodemon by running this command: npm i nodemon -g

And I am receiving this error message below:

npm error code MODULE_NOT_FOUND
npm error path \?\C:\Program Files\nodejs\node_modules\npm\node_modules\tuf-js\node_modules\make-fetch-happen\package.json
npm error Cannot find module 'C:\Program Files\nodejs\node_modules\npm\node_modules\tuf-js\node_modules\make-fetch-happen\lib\index.js'. Please verify that the package.json has a valid "main" entry
npm error A complete log of this run can be found in: C:\Users\mbulelo.tshabane\AppData\Local\npm-cache_logs\2025-03-06T14_33_24_047Z-debug-0.log

I have tried the following command as well below:

npm install nodemon --save-dev

Still same error message received.

Share Improve this question edited Mar 6 at 19:10 Mike 'Pomax' Kamermans 53.8k17 gold badges125 silver badges176 bronze badges asked Mar 6 at 18:32 Mbulelo TshabaneMbulelo Tshabane 133 bronze badges 5
  • Are you able to do any other npm operations? It looks like npm installation is damaged. Try to uninstall node with provided uninstaller and reinstall again – Estus Flask Commented Mar 6 at 18:43
  • Back up a moment: why do you need nodemon? Because "restarting on file changes" may have been useful back in the node 4 days, but these days you want "hot-swap my code without restarting anything, I have a state to preserve". That said: which version of Node are you using? – Mike 'Pomax' Kamermans Commented Mar 6 at 19:10
  • @Mike'Pomax'Kamermans I am using Node v22.14.0 – Mbulelo Tshabane Commented Mar 7 at 5:41
  • (remember to say that in your post, not in a comment) – Mike 'Pomax' Kamermans Commented Mar 7 at 5:42
  • But also again: are you sure you need nodemon? (Because if you really think you do, node has --watch built in, which does the same thing natively, so are you sure you need nodemon?) – Mike 'Pomax' Kamermans Commented Mar 7 at 19:01
Add a comment  | 

2 Answers 2

Reset to default 1

If nodemon isn't working, you can use Nodejs watch function.

node --watch path/to/main.js

There can be 3 reasons behind it:

  1. Try clearing the npm cache:

npm cache clean --force
npm i -g nodemon

  1. If your npm is outdated then update it:

npm install -g npm

  1. Reinstall your node.js. It might be broken.
发布评论

评论列表(0)

  1. 暂无评论