node.js - Node : Cannot find module common

标签 node.js commonjs

我正在运行一个 Node 服务器,没有任何问题,出于某种目的,必须删除 node_modules 目录并重新安装依赖项。这样做并再次运行服务器后,我收到此错误:

Error: Cannot find module './common'
    at Function.Module._resolveFilename (module.js:547:15)
    at Function.Module._load (module.js:474:25)
    at Module.require (module.js:596:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (C:\Work\Cinde-Node\node_modules\debug\src\node.js:236:18)
    at Module._compile (module.js:652:30)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)

我使用npm install common单独安装了common,但这并没有解决问题。

我该如何解决这个问题?

最佳答案

看起来你有这样一行 require('./common'); 它应该是 require('common')

关于node.js - Node : Cannot find module common,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52755446/

相关文章:

javascript - 如何修复导致空对象的循环依赖

google-chrome-extension - Chrome 扩展中的 CommonJS

node.js - 监听 Redis 的变化?

javascript - Browserify+Backbone.js "ApplicationState"共享模块

javascript async/await unhandledRejection 未触发

javascript - ssl 版本或密码不匹配 ExpressJS

javascript - 今天如何打包客户端 Javascript 库?

node.js - TypeScript 外部 Node 模块有时会转换为 module.exports 和导出

node.js - 在 Azure 上运行 NodeJS 命令

node.js - 为 Sails.js 应用程序初始化 MongoDB 数据库和用户的推荐方法是什么?