'Node-sass error deploying to Heroku: ‘remove_cv’ !std::is_same<Data, std::remove_cv_t<T>>::value>::Perform(data);
I've created a Ruby on Rails app. It uses Rails for the backend and frontend. I'm using .scss files for styling.
Been getting this error when trying to deploy my app to 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
Other info from error message:
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.
Have tried several ways to solve this and haven't yet. My Node version is v14.19.0
My package.json file:
{
"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"
}
}
Below are node-sass sections of my yarn.lock file (just noticed there appear to be two versions of node-sass in my yarn.lock file... perhaps this is a partial problem):
[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"
Here is my 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]
My site looks fine on localhost, but trying to deploy to Heroku gives error shown above.
I believe I'm currently using yarn and npm so this could be a partial problem, but not sure if it's the main problem. Also fyi, I recently deleted my package-lock.json.
Not sure what to do for this error. Any help is appreciated.
Solution 1:[1]
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
heroku buildpacks:remove heroku/rails
heroku buildpacks:add heroku/nodejs
heroku buildpacks:add heroku/rails
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | loop |
