【问题标题】:Getting error: Cannot find module 'errno' running node script出现错误:找不到模块 'errno' 运行节点脚本
【发布时间】:2015-12-10 17:11:34
【问题描述】:

我刚刚在新机器上安装了 Ubuntu 15.10、node 4.2.2 和 npm 2.14.7(带有 nvm)的新副本。我已经在全球范围内安装了 webpack 和 webpack-dev-server,并使用 npm i 安装了我的项目依赖项。

现在,当我尝试运行节点服务器时,出现以下错误:

module.js:339
  throw err;
  ^

Error: Cannot find module 'errno'
at Function.Module._resolveFilename (module.js:337:15)
at Function.Module._load (module.js:287:25)
at Module.require (module.js:366:17)
at require (module.js:385:17)
at Object.<anonymous> (/node_modules/webpack-dev-middleware/node_modules/memory-fs/lib/MemoryFileSystem.js:7:14)
at Module._compile (module.js:435:26)
at Object.Module._extensions..js (module.js:442:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:311:12)
at Module.require (module.js:366:17)
at require (module.js:385:17)

有什么建议吗?

【问题讨论】:

    标签: node.js ubuntu webpack


    【解决方案1】:

    Node.js 在程序所在路径的./node_modules/ 目录中搜索模块。

    例如,如果你的脚本在这里/home/user/scripts/somescript.js,你应该有/home/user/scripts/node_modules/。

    只要在这里npm install errno/home/user/scripts/。

    【讨论】:

    • 是的,我认为 'errno' 是我执行 npm i 时应该安装的其他模块的依赖项。我似乎很难正确安装所有项目的依赖项。
    【解决方案2】:

    我的npm install 似乎出了点问题,我的项目依赖项只安装了一部分。再次运行npm install 并没有解决它。我做了一个npm cache clean,删除了我的node_modules 目录,然后再次运行npm install。然后问题就解决了。

    【讨论】:

      猜你喜欢
      • 2018-04-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-08-28
      • 2015-10-09
      • 1970-01-01
      • 1970-01-01
      • 2020-08-07
      相关资源
      最近更新 更多