简体   繁体   English

重新启动时Nodemon应用程序找不到模块

[英]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 installnpm 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.

相关问题 错误:找不到模块,Nodemon 崩溃 - Error: Cannot find module, Nodemon crashes nodemon 错误:错误:找不到模块“vue” - nodemon error: Error: Cannot find module 'vue' 在 docker 容器上运行 nodejs 应用程序会给出“错误:找不到模块'/usr/src/app/nodemon'” - Running a nodejs app on a docker container gives “ Error: Cannot find module '/usr/src/app/nodemon' ” 错误:使用 docker-compose 时找不到模块“/usr/src/app/nodemon” - Error: Cannot find module '/usr/src/app/nodemon' while using docker-compose 运行nodemon时找不到模块“ express”。 引发错误,应用程序崩溃 - Cannot find module 'express' while running nodemon. Throw error, app crashed 运行mocha时找不到配置模块,但运行nodemon时可以工作 - Cannot find config module when running mocha but works when running nodemon Monorepo – Yarn 工作区 Typescript Node.JS 项目 – 运行 nodemon 时找不到模块 - Monorepo – Yarn workspaces Typescript Node.JS project – cannot find module when running nodemon nodemon 找不到模块'/path/to/project/home/index.js' - nodemon Cannot find module '/path/to/project/home/index.js' 错误:无法使用 nodemon 找到模块跨环境 - Error: Cannot find module cross-env using nodemon 节点 Nodemon 错误:找不到模块 'C:\Program Files\Git\node_modules\nodemon\bin\nodemon.js' - Node Nodemon Error: Cannot find module 'C:\Program Files\Git\node_modules\nodemon\bin\nodemon.js'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM