Github action: npm install -> Error: Process completed with exit code 1

Github action: npm install -> Error: Process completed with exit code 1

我的这个 GitHub 动作工作流程已经运行了一年多。当我到达运行 'npm install' 的步骤时突然出现错误。我真的不知道为什么会触发错误。真的很感激有人帮助或至少只是指出我正确的方向。如果您需要更多数据,请告诉我,我会编辑问题。

我已经尝试更新一些软件包以及 npm update 命令。但是不好:

Run npm install
npm WARN old lockfile 
npm WARN old lockfile The package-lock.json file was created with an old version of npm,
npm WARN old lockfile so supplemental metadata must be fetched from the registry.
npm WARN old lockfile 
npm WARN old lockfile This is a one-time fix-up, please be patient...
npm WARN old lockfile 
npm WARN deprecated urix@0.1.0: Please see https://github.com/lydell/urix#deprecated
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 resolve-url@0.2.1: https://github.com/lydell/resolve-url#deprecated
npm WARN deprecated querystring@0.2.0: The querystring API is considered Legacy. new code should use the URLSearchParams API instead.
npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
npm WARN deprecated har-validator@5.1.5: this library is no longer supported
npm WARN deprecated svgo@1.3.2: This SVGO version is no longer supported. Upgrade to v2.x.x.
npm WARN deprecated chokidar@2.1.8: Chokidar 2 will break on node v14+. Upgrade to chokidar 3 with 15x less dependencies.
npm WARN deprecated chokidar@2.1.8: Chokidar 2 will break on node v14+. Upgrade to chokidar 3 with 15x less dependencies.
npm WARN deprecated chokidar@2.1.8: Chokidar 2 will break on node v14+. Upgrade to chokidar 3 with 15x less dependencies.
npm WARN deprecated tar@2.2.2: This version of tar is no longer supported, and will not receive security updates. Please upgrade asap.
npm WARN deprecated popper.js@1.16.1: You can find the new Popper v2 at @popperjs/core, this package is dedicated to the legacy v1
npm WARN deprecated core-js@2.6.12: core-js@<3.3 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Please, upgrade your dependencies to the actual version of core-js.
npm ERR! code 1
npm ERR! path /home/runner/work/projsiteWebApp/projsiteWebApp/node_modules/node-sass
npm ERR! command failed
npm ERR! command sh -c node scripts/build.js
npm ERR! Building: /usr/local/bin/node /home/runner/work/projsiteWebApp/projsiteWebApp/node_modules/node-gyp/bin/node-gyp.js rebuild --verbose --libsass_ext= --libsass_cflags= --libsass_ldflags= --libsass_library=
npm ERR! make: Entering directory '/home/runner/work/projsiteWebApp/projsiteWebApp/node_modules/node-sass/build'
npm ERR!   g++ '-DNODE_GYP_MODULE_NAME=libsass' '-DUSING_UV_SHARED=1' '-DUSING_V8_SHARED=1' '- 

(这里还有一些错误消息,但由于字符太多而不得不中断)

npm ERR!                                       remove_cv
npm ERR! /home/runner/.node-gyp/16.13.1/include/node/v8-internal.h:492:38: error: ‘remove_cv_t’ is not a member of ‘std’
npm ERR! /home/runner/.node-gyp/16.13.1/include/node/v8-internal.h:492:38: note: suggested alternative: ‘remove_cv’
npm ERR!              !std::is_same<Data, std::remove_cv_t<T>>::value>::Perform(data);
npm ERR!                                       ^~~~~~~~~~~
npm ERR!                                       remove_cv
npm ERR! /home/runner/.node-gyp/16.13.1/include/node/v8-internal.h:492:50: error: template argument 2 is invalid
npm ERR!              !std::is_same<Data, std::remove_cv_t<T>>::value>::Perform(data);
npm ERR!                                                   ^
npm ERR! /home/runner/.node-gyp/16.13.1/include/node/v8-internal.h:492:63: error: ‘::Perform’ has not been declared
npm ERR!              !std::is_same<Data, std::remove_cv_t<T>>::value>::Perform(data);
npm ERR!                                                                ^~~~~~~
npm ERR! /home/runner/.node-gyp/16.13.1/include/node/v8-internal.h:492:63: note: suggested alternative: ‘herror’
npm ERR!              !std::is_same<Data, std::remove_cv_t<T>>::value>::Perform(data);
npm ERR!                                                                ^~~~~~~
npm ERR!                                                                herror
npm ERR! make: *** [Release/obj.target/binding/src/binding.o] Error 1
npm ERR! gyp ERR! build error 
npm ERR! gyp ERR! stack Error: `make` failed with exit code: 2
npm ERR! gyp ERR! stack     at ChildProcess.onExit (/home/runner/work/projsiteWebApp/projsiteWebApp/node_modules/node-gyp/lib/build.js:262:23)
npm ERR! gyp ERR! stack     at ChildProcess.emit (node:events:390:28)
npm ERR! gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:290:12)
npm ERR! gyp ERR! System Linux 5.4.0-1064-azure
npm ERR! gyp ERR! command "/usr/local/bin/node" "/home/runner/work/projsiteWebApp/projsiteWebApp/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
npm ERR! gyp ERR! cwd /home/runner/work/projsiteWebApp/projsiteWebApp/node_modules/node-sass
npm ERR! gyp ERR! node -v v16.13.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

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/runner/.npm/_logs/2021-12-13T20_05_37_396Z-debug.log
Error: Process completed with exit code 1.

您的项目中似乎有某些东西正在使用 node-sass,其中包含已弃用的库sass

如果是直接依赖,直接切换到Dart Sass, and things mostly should just work the same. If it is a transitive dependency that is requiring node-sass, you can try to update it by updating your direct dependencies that depend on it. Alternatively, if you're using yarn, you can try to change it with selective version resolutions

即可

如果您无法切换到使用 dart-sass 并且必须处理 C++ gyp 构建错误,我可能会检查以确保特定版本的 node-sass你正在使用的是与你当前安装的当前 c++ 编译器兼容的。也许您的编译器变得太旧了,因为 libsass(反过来,node-sass)决定提高他们的语言要求?

编辑: 尝试使用 (因为您使用的是 npm)将 vue-mj-daterangepicker 中的 node-sass 解析为其他内容。您可以更改为较新的版本或使用“dart-sass”包。如果你使用后者,g++ 不会出错,因为 dart-sass 不使用 c++。您还可以使用“sass”包,因为 sassdart-sass npm 包本质上是相同的

在您的 package.json 中可能有类似以下内容...(未测试)

"resolutions": {
  "node-sass": "https://registry.npmjs.org/node-sass/-/node-sass-7.0.0.tgz"
},
"scripts": {
  "preinstall": "npx npm-force-resolutions"
}

"resolutions": {
  "node-sass": "https://registry.npmjs.org/dart-sass/-/dart-sass-1.25.0.tgz"
},
"scripts": {
  "preinstall": "npx npm-force-resolutions"
}

发生这种情况的原因是因为 libsass 在构建时似乎设置为使用 C++11 标准,但 std::remove_cv_t 仅作为 C++14 标准的一部分引入(我认为像 MSVC 这样的编译器可能比这更早引入它)。一个简单的解决方法是在 运行 npm install 之前设置 CXXFLAGS 环境变量。例如CXXFLAGS="--std=c++14" npm install