Node error: Cannot find module 'contextify' with Yarn and Webpack

Node error: Cannot find module 'contextify' with Yarn and Webpack

我正在尝试 运行 一个应用程序(我会继续开发)使用:

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。有什么想法吗?

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

1) Python 未安装:

  • 安装Python2.7
  • 设置 npm 查找 python: npm config set python <python.path>\python.exe 其中 python.path 是您安装 python 的路径(例如 C:\Python2.7

2) 在防火墙/代理后面

  • 使用命令:npm config set proxy <proxyUrl>

3) Problem with node-sass代理阻塞时出现问题 节点-sass 文件。

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

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