运行npm install时出错,返回“This is a bug in 'node-gyp'”

3
我是新手Angular和Node。我正在尝试执行使用Angular,Neo4j创建的项目。一开始,我尝试按原样运行它。然而,在打开浏览器后,我遇到了以下错误:
NullInjectorError: StaticInjectorError(AppModule)[RouterScroller -> >ViewportScroller]: StaticInjectorError(Platform: core)[RouterScroller -> ViewportScroller]: NullInjectorError: No provider for ViewportScroller!
ERROR Error: Uncaught (in promise): Neo4jError: WebSocket连接失败。由于您的Web浏览器中的安全限制,故障的原因对于此Neo4j驱动程序不可用。请使用您的浏览器开发控制台确定故障的根本原因。常见原因包括数据库不可用,使用错误的连接URL或临时网络问题。如果启用了加密,请确保您的浏览器配置为信任Neo4j配置使用的证书。WebSocket readyState is: 3 Neo4jError: WebSocket连接失败。由于您的Web浏览器中的安全限制,故障的原因对于此Neo4j驱动程序不可用。请使用您的浏览器开发控制台确定故障的根本原因。常见原因包括数据库不可用,使用错误的连接URL或临时网络问题。如果启用了加密,请确保您的浏览器配置为信任Neo4j配置使用的证书。WebSocket readyState is: 3
然后,我尝试了一个干净的安装,按照以下过程进行:
1.从项目中删除node_modules; 2.运行npm install --global windows-build-tools 3.运行npm install
然后我遇到了这个错误:
gyp ERR! UNCAUGHT EXCEPTION
gyp ERR! stack Error: spawn C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\15.0\Bin\MSBuild.exe ENOENT
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:269:19)
gyp ERR! stack     at onErrorNT (internal/child_process.js:465:16)
gyp ERR! stack     at processTicksAndRejections (internal/process/task_queues.js:80:21)
gyp ERR! System Windows_NT 10.0.19041
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\USER_NAME\\PROJECT\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
gyp ERR! cwd C:\Users\USER_NAME\PROJECT\node_modules\node-sass
gyp ERR! node -v v14.15.1
gyp ERR! node-gyp -v v3.8.0
gyp ERR! This is a bug in `node-gyp`.
gyp ERR! Try to update node-gyp and file an Issue if it does not help:
gyp ERR!     <https://github.com/nodejs/node-gyp/issues>

抱歉内容有点长。有什么建议可以解决这个问题吗?


编辑:

我还尝试了以下方法:

  1. Rebuilding the node-gyp bindings by running node-gyp rebuild, however that returns the following error:

    binding.gyp not found while trying to load binding.gyp
    gyp ERR! configure error
    gyp ERR! System Windows_NT 10.0.19041
    gyp ERR! node -v v14.15.1 gyp ERR! node-gyp -v v7.1.2
    
  2. I can confirm that node-gyp is installed globally because I ran: npm install -g node-gyp

  3. I tried the gyp rebuild using python 2.7.18 to no avail. Still returning the same error.

编辑2:

我已经无法访问该项目。因此,我无法测试任何新的解决方案。

不管怎样,谢谢大家的帮助。


这是由于Python版本的问题,安装Xcode并重新安装所有的Node包即可解决。 - Gaurav Varshney
你是在 vscode 里运行它吗?如果是的话,试试用像 cmder 这样的命令行工具来运行。 - Daniel Jeney
@DanielJeney 是的,它是在vscode上。不幸的是,我不再参与这个项目,也无法访问文件了。但是,谢谢你的建议,我会记住它以备下次使用。 - Fernando
2个回答

0

对我来说,这个问题通过使用 Node 版本 14 得到了解决。

首先使用 Docker 进行测试:docker pull node:14.10.0


0
这是一个已知的画布问题,可能是由于缺少本地库引起的。 尝试这个看看是否有帮助:
sudo npm uninstall -g node-gyp
sudo npm install -g node-gyp
brew install pkg-config cairo libpng jpeg giflib
npm i canvas

问题是关于Windows(如windows-build-tools)而不是MacOS。 - bruno.braga

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接