【问题标题】:Nodemon app cannot find module when restartingNodemon应用程序在重新启动时找不到模块
【发布时间】:2020-01-06 07:50:13
【问题描述】:

我目前正在构建一个 RESTful API。我使用命令mongod 启动我的MongoDB 服务器。但是,当我重新启动 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...

我用谷歌搜索了这个错误,解决方案似乎是删除node_modules 目录。但是,当我输入rm -rf nodes_modules 时,它显示找不到该命令。我也尝试使用npm installnpm start,但这也会引发错误。我做错了什么?

【问题讨论】:

  • 你的问题是什么?
  • 您是要删除node_modules,还是nodes_modules
  • @IronFlare 徒劳

标签: node.js visual-studio-code node-modules


【解决方案1】:

我通过修复路径来解决问题!好吧,当我输入 npm install 和 npm start 时!它显示一个错误,确认默认情况下该文件在路径中不可用! (就我而言)C/users/Zakaria/package.json !!当我寻找那个文件时,我没有找到它!因此,我必须更改包含我的 package.json 文件的路径。我使用了该命令“npm start --prefix TheRealPath”因此,RESTful API 在端口:3000 上启动! :P

【讨论】:

    猜你喜欢
    • 2018-12-06
    • 2013-08-23
    • 2022-01-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-05-09
    • 2017-08-14
    • 2016-09-18
    相关资源
    最近更新 更多