执行 npm install 失败,显示错误“绑定.gyp 中未定义变量standalone_static_library”和 node-sass chokidar 错误

Ste*_*eda 15 javascript ruby-on-rails package npm reactjs

我正在更新 3 年前的 ruby​​ on Rails 和 React 项目,尝试 npm install 但我被困在这里收到此错误

$ npm 安装

gyp: Undefined variable standalone_static_library in binding.gyp while trying to load binding.gyp
gyp ERR! configure error 
gyp ERR! stack Error: `gyp` failed with exit code: 1
Run Code Online (Sandbox Code Playgroud)

$ npm 开始

sh: node-sass-chokidar: command not found
npm ERR! code ELIFECYCLE
npm ERR! syscall spawn
npm ERR! file sh
npm ERR! errno ENOENT
npm ERR! frontend@0.1.0 build-css: `node-sass-chokidar src/styles -o src/styles`
npm ERR! spawn ENOENT
npm ERR! 
npm ERR! Failed at the frontend@0.1.0 build-css script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
Run Code Online (Sandbox Code Playgroud)

我尝试删除node_modules,更新node版本和npm版本。

The*_*Pea 9

对我来说,这个问题发生在 NodeJS 19(特别是 19.2.0)上

当我恢复到 NodeJS 18 时,问题得到解决;又名 NodeJS LTS

NodeJS LTS = 长期支持;“推荐给大多数用户”。在我写这个答案时(12/9/2022),Node 长期支持(LTS)是NodeJS 版本 18.12.1

出现这个问题( )的原因可能Undefined variable standalone_static_library...是:

节点 19.0.0 已更改为使 process.config 只读#43627

恢复后,它可能仍会被提及为警告,但不是错误:

npm 错误!(节点:7120)[DEP0150] DeprecationWarning:不推荐使用设置 process.config。将来该属性将是只读的。

当我们谈论版本时,请注意 Python3 与 Python2!

npm 错误!gyp 动词which失败错误:未找到:python2