10

Ruby 2.7.4 Rails 6.1.4.1

note: in package.json the engines key is missing in my app

Heroku fails during build with this error

this commit is an empty commit on top of exactly a SHA that I was successful at pushing yesterday (I've checked twice now) so I suspect this is a platform problem or somehow the node-sass got deprecated or yanked yesterday?

how can I fix this?

remote:        
remote:        ERROR in ./app/javascript/require_bootstrap.scss
remote:        Module build failed (from ./node_modules/mini-css-extract-plugin/dist/loader.js):
remote:        ModuleBuildError: Module build failed (from ./node_modules/sass-loader/dist/cjs.js):
**remote:        Error: Node Sass does not yet support your current environment: Linux 64-bit with Unsupported runtime (93)**
remote:        For more information on which environments are supported please see:
remote:        https://github.com/sass/node-sass/releases/tag/v4.14.1
remote:            at module.exports (/tmp/build_1c436dcf/node_modules/node-sass/lib/binding.js:13:13)
remote:            at Object.<anonymous> (/tmp/build_1c436dcf/node_modules/node-sass/lib/index.js:14:35)
remote:            at Module._compile (/tmp/build_1c436dcf/node_modules/v8-compile-cache/v8-compile-cache.js:192:30)
remote:            at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)

Jason FB
  • 4,752
  • 3
  • 38
  • 69

2 Answers2

37

Heroku switched the default Node from 14 to 16 in Dec 2021 for the Ruby buildpack .

Heroku updated the heroku/ruby buildpack Node version from Node 14 to Node 16 (see https://devcenter.heroku.com/changelog-items/2306) which is not compatible with the version of Node Sass locked in at the Webpack version you're likely using.

To fix it do these two things:

  1. Specify the 14.x Node version in package.json.
# In package.json
{
  # ...
  "engines": {
    "node": "14.x"
  },
  # ...
}
  1. Add the heroku/nodejs buildpack before the heroku/ruby buildpack. You can do this in the web interface or with the command line. Here is the command for the CLI:
$ heroku buildpacks:add heroku/nodejs -i 1 -a YOUR-APP-NAME

With the NodeJS buildpack running first, it will look at the package.json file and respect that when choosing which version of Node to install. Then the Ruby buildpack will run and since a version of Node already exists it will just use that and everything should work as before.

tpett
  • 846
  • 6
  • 7
  • 3
    Boom! Your answer is better than Heroku's (who said the same thing). Also they pointed me to this Dec 2021 change ... who knew... https://devcenter.heroku.com/changelog-items/2306 – Jason FB Dec 17 '21 at 18:00
  • Running only step 2 fixed the problem for me. I didn't need to specify 14.x Node in my `package.json` – Anthony To Dec 21 '21 at 04:52
  • Currently the `heroku/nodejs` package defaults to Node 14, but that will change at some point just like the `heroku/ruby` buildpack did. If you specify that you require Node 14 (as step 1 describes above), you will not have trouble when they change the default to Node 16. – tpett Dec 21 '21 at 20:25
  • 1
    Not all heroes wear capes. Some are improving lives through answers like this! I was completely clueless and the error message made me think I missed up something in my branches, although I'm sure I haven't. Thanks so much! – Bashar Abdullah Jan 03 '22 at 19:52
  • 1
    I had the same problem, the app depends on node 14.x.x but Heroku installed 16.x.x. Keep in mind that in the Heroku admin panel, the `heroku/nodejs` buildpack **MUST** be located before the `heroku/ruby` buildpack. – bmalets Jan 06 '22 at 23:30
  • I had the same problem. To make it work, I had to remove all heroku buildpacks first, then add (in this order) the `heroku/nodejs` and then `heroku/ruby`. – DoubleD Mar 27 '22 at 19:11
2

The solution to this problem was quite different in my situation. Updating the webpacker gem from 3.5.5 to 5.4.3 made the error disappear.

Asad Shakil
  • 123
  • 2
  • 11