更新节点版本后无法在 GCP 上部署 React

Unable to deploy React on GCP after updating node version

节点更新到V16后无法在GCP appengine上部署,可能是由于node-sass !?

在我的本地我做了 npm rebuild node-sass 并且它正在工作,我还更新了我的 .yaml 文件以进行部署所以现在它有一个 runtime: nodejs16(见下文), 我还清理了本地和服务器上的 npm 缓存,在本地删除了 node_modules 并安装了它们,删除了我的构建并重新构建。

//my app.yaml
runtime: nodejs16
service : default

我遇到了错误

ERROR: (gcloud.app.deploy) Error Response: [9] Cloud build de54c08e-fc55-491d-b500-26e06849b2c5 status: FAILURE
...stCheck(T*)':
npm ERR! /www-data-home/.cache/node-gyp/16.9.1/include/node/v8-internal.h:489:38: error: 'remove_cv_t' is not a member of 'std'
npm ERR!              !std::is_same<Data, std::remove_cv_t<T>>::value>::Perform(data);
npm ERR!                                       ^~~~~~~~~~~
npm ERR! /www-data-home/.cache/node-gyp/16.9.1/include/node/v8-internal.h:489: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! /www-data-home/.cache/node-gyp/16.9.1/include/node/v8-internal.h:489:38: error: 'remove_cv_t' is not a member of 'std'
npm ERR! /www-data-home/.cache/node-gyp/16.9.1/include/node/v8-internal.h:489: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! /www-data-home/.cache/node-gyp/16.9.1/include/node/v8-internal.h:489: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! /www-data-home/.cache/node-gyp/16.9.1/include/node/v8-internal.h:489: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! /www-data-home/.cache/node-gyp/16.9.1/include/node/v8-internal.h:489: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 (/workspace/node_modules/node-gyp/lib/build.js:194:23)
npm ERR! gyp ERR! stack     at ChildProcess.emit (node:events:394: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-1052-gcp
npm ERR! gyp ERR! command "/usr/bin/node" "/workspace/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
npm ERR! gyp ERR! cwd /workspace/node_modules/node-sass
npm ERR! gyp ERR! node -v v16.9.1
npm ERR! gyp ERR! node-gyp -v v7.1.2
npm ERR! gyp ERR! not ok
npm ERR! Build failed with error code: 1

感谢您的帮助,谢谢。

刚找到解决办法,其实是我的node-sass版本和我的node版本不兼容 实际上我有一个 node-sass V5+ 而有一个节点 v16,我必须至少有一个 node-sass V6.