npm 安装失败; node_modules 消失

npm install fails; node_modules disappearing

如果这个问题被误导,我们深表歉意;我刚刚获得了一个网站的所有权,该网站的样式和脚本资产由 grunt、npm 等管理。这有点超出了我的驾驶室(我是一名软件开发人员;我正在处理该网站,直到我们可以聘请替代者).

我正在尝试完成对 CSS 文件进行更改然后重新编译资产的过程。 (如果重要的话,这是一个 drupal8 站点。)

我的问题是,当我通过在自定义主题目录中键入 npm install 来启动此过程时,我看到以下输出:

npm WARN deprecated har-validator@5.1.5: this library is no longer supported
npm WARN deprecated graceful-fs@1.2.3: please upgrade to graceful-fs 4 for compatibility with current and future versions of Node.js
npm WARN deprecated minimatch@0.2.14: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
npm WARN deprecated minimatch@0.3.0: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
npm WARN deprecated uuid@3.4.0: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.
npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
npm WARN deprecated coffee-script@1.3.3: CoffeeScript on NPM has moved to "coffeescript" (no hyphen)
npm WARN deprecated uglify-es@3.3.9: support for ECMAScript is superseded by `uglify-js` as of v3.13.0
npm ERR! code 1
npm ERR! path /Users/mefron/devel/uvamiller_local/prod/docroot/themes/custom/miller/node_modules/node-sass
npm ERR! command failed
npm ERR! command sh -c node scripts/build.js
npm ERR! Building: /usr/local/Cellar/node/16.6.1/bin/node /Users/mefron/devel/uvamiller_local/prod/docroot/themes/custom/miller/node_modules/node-gyp/bin/node-gyp.js rebuild --verbose --libsass_ext= --libsass_cflags= --libsass_ldflags= --libsass_library=
npm ERR!   c++ '-DNODE_GYP_MODULE_NAME=libsass' '-DUSING_UV_SHARED=1' '-DUSING_V8_SHARED=1' '-DV8_DEPRECATION_WARNINGS=1' '-DV8_DEPRECATION_WARNINGS' '-DV8_IMMINENT_DEPRECATION_WARNINGS' '-D_GLIBCXX_USE_CXX11_ABI=1' '-D_DARWIN_USE_64_BIT_INODE=1' '-D_LARGEFILE_SOURCE' '-D_FILE_OFFSET_BITS=64' '-DLIBSASS_VERSION="3.3.6"' -I/Users/mefron/.node-gyp/16.6.1/include/node -I/Users/mefron/.node-gyp/16.6.1/src -I/Users/mefron/.node-gyp/16.6.1/deps/openssl/config -I/Users/mefron/.node-gyp/16.6.1/deps/openssl/openssl/include -I/Users/mefron/.node-gyp/16.6.1/deps/uv/include -I/Users/mefron/.node-gyp/16.6.1/deps/zlib -I/Users/mefron/.node-gyp/16.6.1/deps/v8/include -I../src/libsass/include  -O3 -gdwarf-2 -mmacosx-version-min=10.7 -arch x86_64 -Wall -Wendif-labels -W -Wno-unused-parameter -std=c++11 -stdlib=libc++ -fno-strict-aliasing -MMD -MF ./Release/.deps/Release/obj.target/libsass/src/libsass/src/ast.o.d.raw   -c -o Release/obj.target/libsass/src/libsass/src/ast.o ../src/libsass/src/ast.cpp
...
[huge dump here]
...
npm ERR! gyp ERR! System Darwin 20.6.0
npm ERR! gyp ERR! command "/usr/local/Cellar/node/16.6.1/bin/node" "/Users/mefron/devel/uvamiller_local/prod/docroot/themes/custom/miller/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
npm ERR! gyp ERR! cwd /Users/mefron/devel/uvamiller_local/prod/docroot/themes/custom/miller/node_modules/node-sass
npm ERR! gyp ERR! node -v v16.6.1
npm ERR! gyp ERR! node-gyp -v v3.8.0
npm ERR! gyp ERR! not ok 
npm ERR! Build failed with error code: 1

在此之后,列出目录内容时没有显示我希望看到的 node_modules 子目录的迹象,我假设后续的编译步骤将依赖于它。

我注意到的一件事是,当我等待 npm install 完成时,node_modules 目录存在并且充满了好东西。当 npm 被炸毁时(或之后)不知何故它会被炸毁。

任何关于我如何前进的想法都将不胜感激。

如果有帮助,我的设置详细信息包括: OS: Mac OS 11.5 节点:v16.6.1 npm:7.20.3 节点和 npm 是通过自制软件安装的。我尝试卸载并重新安装它们,但无济于事。

你的项目是旧的,node gyp 不支持新的 node 版本。使用 nvm 降级节点版本,然后使用 npm install。尝试节点 6.x

https://gist.github.com/d2s/372b5943bce17b964a79