如何规避 Heroku 添加 x86_64-linux 错误

How to circumvent Heroku adding x86_64-linux error

我正在尝试将我的应用程序推送到 heroku,每当我尝试此操作时,它都会引发一个错误,要求将 x86_64-linux 添加到我的平台,这对于 bundler 2.2.3+ 来说显然是正常的。这不是问题,但是当我这样做时,预编译资产会出现错误。

remote:        /app/.node-gyp/16.13.1/include/node/v8-internal.h:492:38: error: 
‘remove_cv_t’ is not a member of ‘std’; did you mean ‘remove_cv’?
remote:          492 |             !std::is_same<Data, 
std::remove_cv_t<T>>::value>::Perform(data);
remote:              |                                      ^~~~~~~~~~~
remote:              |                                      remove_cv
remote:        /app/.node-gyp/16.13.1/include/node/v8-internal.h:492:38: error: 
‘remove_cv_t’ is not a member of ‘std’; did you mean ‘remove_cv’?
remote:          492 |             !std::is_same<Data, 
std::remove_cv_t<T>>::value>::Perform(data);
remote:              |                                      ^~~~~~~~~~~
remote:              |                                      remove_cv
remote:        /app/.node-gyp/16.13.1/include/node/v8-internal.h:492:50: error: 
template argument 2 is invalid
remote:          492 |             !std::is_same<Data, 
std::remove_cv_t<T>>::value>::Perform(data);
remote:              |                                                  ^
remote:        /app/.node-gyp/16.13.1/include/node/v8-internal.h:492:63: error: 
‘::Perform’ has not been declared
remote:          492 |             !std::is_same<Data, 
std::remove_cv_t<T>>::value>::Perform(data);
remote:              |                                                               
^~~~~~~

remote:        /app/.node-gyp/16.13.1/include/node/node.h:855:3: note: in expansion 
of macro ‘NODE_MODULE_X’
remote:          855 |   NODE_MODULE_X(modname, regfunc, NULL, 0)  // NOLINT 
(readability/null_usage)
remote:              |   ^~~~~~~~~~~~~
remote:        ../src/binding.cpp:358:1: note: in expansion of macro ‘NODE_MODULE’
remote:          358 | NODE_MODULE(binding, RegisterModule);
remote:              | ^~~~~~~~~~~
remote:        make: *** [binding.target.mk:133: 
Release/obj.target/binding/src/binding.o] Error 1
remote:        make: Leaving directory '/tmp/build_cfb0d744/node_modules/node- 
sass/build'
remote:        gyp ERR! build error 
remote:        gyp ERR! stack Error: `make` failed with exit code: 2
remote:        gyp ERR! stack     at ChildProcess.onExit 
(/tmp/build_cfb0d744/node_modules/node-gyp/lib/build.js:262:23)
remote:        gyp ERR! stack     at ChildProcess.emit (node:events:390:28)
remote:        gyp ERR! stack     at Process.ChildProcess._handle.onexit 
(node:internal/child_process:290:12)
remote:        gyp ERR! System Linux 4.4.0-1098-aws
remote:        gyp ERR! command "/tmp/build_cfb0d744/bin/node" 
"/tmp/build_cfb0d744/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--verbose" "-- 
libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
remote:        gyp ERR! cwd /tmp/build_cfb0d744/node_modules/node-sass
remote:        gyp ERR! node -v v16.13.1
remote:        gyp ERR! node-gyp -v v3.8.0
remote:        gyp ERR! not ok 
remote:        Build failed with error code: 1

据我所知,出现的问题是我的节点版本和我的节点-sass 版本不兼容,但是当我在终端中检查我的节点版本时,它的 v14.15.5 和我的节点- sass 是兼容的 4.14.1。但是,正如您在错误中看到的那样,它表示节点版本为 16.13.1。我相信这是因为当我推送到 heroku 时它说这个

remote: -----> Installing node-v16.13.1-linux-x64
remote: -----> Installing yarn-v1.22.17
remote: -----> Detecting rake tasks
remote: -----> Preparing app for Rails asset pipeline

所以如果安装 linux-x64 就是在安装 node-v16.13.1,它与我的 node-sass 不兼容。有谁知道我该如何解决这个问题。

非常感谢你的帮助,我真的卡住了。

确保激活 heroku/nodejs buildpack 和 add an engines section to your package.json(或更新已有的):

{
  "name": "...",
  "description": "...",
  "version": "...",
  "engines": {
    "node": "14.x"
  }
}

然后提交并重新部署。