【问题标题】:Node error: Cannot find module 'contextify' with Yarn and Webpack节点错误:使用 Yarn 和 Webpack 找不到模块“contextify”
【发布时间】:2019-05-04 19:29:49
【问题描述】:

我正在尝试运行一个应用程序(我将继续工作),使用:

yarn start

但我得到了错误:

ts-node ./src/engine/server/server
Error: Cannot find module 'contextify'
  at Function.Module._resolveFilename (internal/modules/cjs/loader.js:580:15)
  at Function.Module._load (internal/modules/cjs/loader.js:506:25)
  at Module.require (internal/modules/cjs/loader.js:636:17)
  at require (internal/modules/cjs/helpers.js:20:18)
  at Object.<anonymous> (/Users/aa/Documents/app/node_modules/jsdom/lib/jsdom/browser/index.js:5:21)
  at Module._compile (internal/modules/cjs/loader.js:688:30)
  at Object.Module._extensions..js (internal/modules/cjs/loader.js:699:10)
  at Module.load (internal/modules/cjs/loader.js:598:32)
  at tryModuleLoad (internal/modules/cjs/loader.js:537:12)
  at Function.Module._load (internal/modules/cjs/loader.js:529:3)

依赖contextify 不在package.json 中。我尝试了不同的节点版本,但我得到了相同的结果。该应用程序使用 Webpack 在 TypeScript 中。我用的是 Mac。有什么想法吗?

【问题讨论】:

  • 你在使用 npm install 的时候有什么错误吗?
  • @JFPicard 当我运行npm install 时出现错误gyp ERR! stack Error: 'gyp' failed with exit code: 1 之后,如果我运行yarn start 我会收到另一个错误err = new Error('Could not locate the bindings file. Tried:\n' 但是当我使用yarn install 安装时我得到了上述错误。所有者已经使用yarn 运行应用程序,所以问题出在我的机器(Mac)上。

标签: typescript webpack yarnpkg


【解决方案1】:

gyp 错误可能来自以下三点:

1) 未安装 Python:

  • 安装 Python 2.7
  • 设置npm查找python:npm config set python &lt;python.path&gt;\python.exe 其中 python.path 是您安装 python 的路径(例如C:\Python2.7

2) 在防火墙/代理之后

  • 使用命令:npm config set proxy &lt;proxyUrl&gt;

3) node-sass的问题代理阻塞时出现问题 node-sass 文件。

您可能需要更改文件,因为有时它会要求win32-x64-59_binding.node

【讨论】:

  • 感谢您的回答,但我忘了提及我使用的是 Mac。我尝试了第一个解决方案,但没有奏效。第二个不适用,因为我不在代理后面。我在本地运行服务器。第三个无关紧要,因为它与 Windows 有关。
  • 也许这会有所帮助:stackoverflow.com/questions/38058386/…
  • 这个问题好像很大! Node-gyp、yarn 等……它从来没有用过 :(
【解决方案2】:

问题原来是节点 6.x.x。 C++编译配置问题。 This comment 帮我解决了。

【讨论】:

    猜你喜欢
    • 2017-01-08
    • 2015-10-09
    • 2021-02-13
    • 2016-07-23
    • 2015-06-12
    • 1970-01-01
    • 2019-08-28
    相关资源
    最近更新 更多