[英]Nodemon app cannot find module when restarting
I'm currently building a RESTful API.我目前正在构建一个 RESTful API。 I start my MongoDB server using the command mongod
.我使用命令mongod
启动我的 MongoDB 服务器。 When I restart my Node server (using rs
), however, it throws the following error:但是,当我重新启动 Node 服务器(使用rs
)时,它会引发以下错误:
[nodemon] starting `node todoListApi`
internal/modules/cjs/loader.js:638
throw err;
^
Error: Cannot find module 'C:\Users\Zakaria5\Desktop\Stage Technique
2019\zen-networks-backend\todoListApi'
at Function.Module._resolveFilename
(internal/modules/cjs/loader.js:636:15)
at Function.Module._load (internal/modules/cjs/loader.js:562:25)
at Function.Module.runMain (internal/modules/cjs/loader.js:831:12)
at startup (internal/bootstrap/node.js:283:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:622:3)
[nodemon] app crashed - waiting for file changes before starting...
I Googled this error, and the solution seemed to be to remove the node_modules
directory.我用谷歌搜索了这个错误,解决方案似乎是删除node_modules
目录。 However, when I type rm -rf nodes_modules
, it displays that the command is not found.但是,当我输入rm -rf nodes_modules
,它显示未找到该命令。 I also tried using npm install
and npm start
, but this throws an error, as well.我也尝试使用npm install
和npm start
,但这也会引发错误。 What am I doing wrong?我究竟做错了什么?
I resolve the problem by fixing the path !!我通过修复路径来解决问题! Well , when i type npm install and npm start !好吧,当我输入 npm install 和 npm start 时! It displays an error which confirms that the file isnt available in a path by default !!它显示一个错误,确认默认情况下该文件在路径中不可用!! (in my case) C/users/Zakaria/package.json !! (就我而言)C/users/Zakaria/package.json !! when i look for that file i didnt find it !当我寻找那个文件时我没有找到它! Thus , I have to change the path which contains my package.json file .因此,我必须更改包含我的 package.json 文件的路径。 I used that command " npm start --prefix TheRealPath " Hence , the RESTful API starts on port : 3000 !!我使用了该命令“npm start --prefix TheRealPath” 因此,RESTful API 在端口 3000 上启动! :P :P
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.