Node-sass 部署到 Heroku 时出错:‘remove_cv’ !std::is_same<数据,std::remove_cv_t>::值>::执行(数据);
我创建了一个 Ruby on Rails 应用程序。它使用 Rails 作为后端和前端。我使用 .scss
文件进行样式设置。
尝试将我的应用程序部署到 Heroku 时出现此错误:
/app/.node-gyp/16.13.1/include/node/v8-internal.h:492:38: error: ‘remove_cv_t’ is not a member of ‘std’
remote: /app/.node-gyp/16.13.1/include/node/v8-internal.h:492:38: note: suggested alternative: ‘remove_cv’
remote: !std::is_same<Data, std::remove_cv_t<T>>::value>::Perform(data);
remote: ^~~~~~~~~~~
remote: remove_cv
错误消息中的其他信息:
gyp ERR! build error
remote: gyp ERR! stack Error: `make` failed with exit code: 2
remote: gyp ERR! stack at ChildProcess.onExit (/tmp/build_7da73fb3/node_modules/@rails/webpacker/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_7da73fb3/bin/node" "/tmp/build_7da73fb3/node_modules/@rails/webpacker/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
remote: gyp ERR! cwd /tmp/build_7da73fb3/node_modules/@rails/webpacker/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
remote:
remote: !
remote: ! Precompiling assets failed.
remote: !
remote: ! Push rejected, failed to compile Ruby app.
已尝试多种方法来解决此问题,但尚未解决。我的 Node 版本是 v14.19.0
我的 package.json 文件:
{
"name": "Nail_The_Trail",
"private": true,
"dependencies": {
"@rails/actioncable": "^6.0.0",
"@rails/activestorage": "^6.0.0",
"@rails/ujs": "^6.0.0",
"@rails/webpacker": "4.3.0",
"dart-sass": "^1.25.0",
"node-sass": "6.0.1",
"sass": "^1.49.7",
"sass-loader": "^12.6.0",
"turbolinks": "^5.2.0"
},
"version": "0.1.0",
"devDependencies": {
"webpack-dev-server": "^3.11.2"
}
}
下面是我的yarn.lock 文件的node-sass 部分(刚刚注意到我的yarn.lock 文件中似乎有两个版本的node-sass...也许这是部分问题):
[email protected]:
version "6.0.1"
resolved "https://registry.yarnpkg.com/node-sass/-/node-sass-6.0.1.tgz#cad1ccd0ce63e35c7181f545d8b986f3a9a887fe"
integrity sha512-f+Rbqt92Ful9gX0cGtdYwjTrWAaGURgaK5rZCWOgCNyGWusFYHhbqCCBoFBeat+HKETOU02AyTxNhJV0YZf2jQ==
dependencies:
async-foreach "^0.1.3"
chalk "^1.1.1"
cross-spawn "^7.0.3"
gaze "^1.0.0"
get-stdin "^4.0.1"
glob "^7.0.3"
lodash "^4.17.15"
meow "^9.0.0"
nan "^2.13.2"
node-gyp "^7.1.0"
npmlog "^4.0.0"
request "^2.88.0"
sass-graph "2.2.5"
stdout-stream "^1.4.0"
"true-case-path" "^1.0.2"
node-sass@^4.13.0:
version "4.14.1"
resolved "https://registry.yarnpkg.com/node-sass/-/node-sass-4.14.1.tgz#99c87ec2efb7047ed638fb4c9db7f3a42e2217b5"
integrity sha512-sjCuOlvGyCJS40R8BscF5vhVlQjNN069NtQ1gSxyK1u9iqvn6tf7O1R4GNowVZfiZUCRt5MmMs1xd+4V/7Yr0g==
dependencies:
async-foreach "^0.1.3"
chalk "^1.1.1"
cross-spawn "^3.0.0"
gaze "^1.0.0"
get-stdin "^4.0.1"
glob "^7.0.3"
in-publish "^2.0.0"
lodash "^4.17.15"
meow "^3.7.0"
mkdirp "^0.5.1"
nan "^2.13.2"
node-gyp "^3.8.0"
npmlog "^4.0.0"
request "^2.88.0"
sass-graph "2.2.5"
stdout-stream "^1.4.0"
"true-case-path" "^1.0.2"
这是我的 gemfile:
source "https://rubygems.org"
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
ruby "2.6.1"
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'sassc-rails'
gem "rails", "~> 6.0.3", ">= 6.0.3.4"
# Use sqlite3 as the database for Active Record
gem "pg"
# Use Puma as the app server
gem "puma", "~> 4.1"
# Use SCSS for stylesheets
# Transpile app-like JavaScript. Read more: https://github.com/rails/webpacker
gem "webpacker", "~> 4.0"
# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
gem "turbolinks", "~> 5"
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem "jbuilder", "~> 2.7"
# Use Redis adapter to run Action Cable in production
# gem 'redis', '~> 4.0'
# Use Active Model has_secure_password
# gem 'bcrypt', '~> 3.1.7'
# Use Active Storage variant
# gem 'image_processing', '~> 1.2'
# Reduces boot times through caching; required in config/boot.rb
gem "bootsnap", ">= 1.4.2", require: false
gem "bcrypt", "~> 3.1.7"
gem "omniauth", "~> 2.0.4"
gem "omniauth-facebook"
gem "omniauth-rails_csrf_protection", "~> 1.0"
group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem "byebug", platforms: [:mri, :mingw, :x64_mingw]
end
group :development do
# Access an interactive console on exception pages or by calling 'console' anywhere in the code.
gem "web-console", ">= 3.3.0"
gem "listen", "~> 3.2"
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem "spring"
gem "spring-watcher-listen", "~> 2.0.0"
gem "pry", "~> 0.13.1"
gem "pry-rails"
gem "faker"
gem "omniauth", "~> 2.0.4"
gem "omniauth-facebook"
gem "omniauth-rails_csrf_protection", "~> 1.0"
end
group :test do
# Adds support for Capybara system testing and selenium driver
gem "capybara", ">= 2.15"
gem "selenium-webdriver"
# Easy installation and use of web drivers to run system tests with browsers
gem "webdrivers"
end
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem "tzinfo-data", platforms: [:mingw, :mswin, :x64_mingw, :jruby]
我的网站在本地主机上看起来很好,但尝试部署到 Heroku 会出现上面显示的错误。
我相信我目前正在使用yarn和npm,所以这可能是一个部分问题,但不确定这是否是主要问题。另外仅供参考,我最近删除了我的 package-lock.json。
不知道该怎么办这个错误。任何帮助表示赞赏。
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这可能与heroku默认提供node 16.x有关,而node-sass不喜欢它,更喜欢14.x;
我可以通过在 package.json 中放入
"engines" : { "node": "14.19.1" },
来使用 14.x ,然后在本地使用该版本 (nvm install 14.19.1 ;nvm 使用 14.19.1),并且在 heroku 上,确保在 ruby 构建包之前添加 Nodejs 构建包(请参阅 https://devcenter.heroku.com/articles/ruby-support#installed-binaries< /a>),我是这样做的
It may have to do with heroku providing a node 16.x by default, and node-sass not liking it, preferring a 14.x;
I was able to use 14.x by putting:
"engines" : { "node": "14.19.1" },
in package.json, then locally using that version (nvm install 14.19.1; nvm use 14.19.1), and, on heroku, by making sure that you add the nodejs buildpack before the ruby one (see https://devcenter.heroku.com/articles/ruby-support#installed-binaries), which I did by