DEV Community

Axel Mukwena
Axel Mukwena

Posted on • Updated on

Heroku error /node_modules/node-sass: Command failed

If during build you are getting: error /tmp/build_1bb645c1/node_modules/node-sass: Command failed.

On 16 December 2021, Heroku changed the Node version to 16.13.1 (which was previously 12.16.2). Since we have dependencies such as node-sass v4.14.1 which requires Node v14, we need to specify the Node version Heroku should use.

  • First, we need to use multiple buildpacks, which will specify to install Node first then install Ruby (Read more from Heroku).

Please make you install them in the order below

$ heroku buildpacks:add heroku/nodejs
$ heroku buildpacks:add heroku/ruby
  • Verify that the buildpacks are installed
$ heroku buildpacks

>>>

  1. heroku/nodejs
  2. heroku/ruby
  • If buildpacks are not in the order above, remove each of them and add them again. If, for example, ruby comes first, you can just remove it, then add it again as below.
$ heroku buildpacks:remove heroku/ruby

Add it again

$ heroku buildpacks:add heroku/ruby

Now you should have the correct ordering.

{
  ...
  "engines": {
    "node": "14.x"
  },
  ...
}
  • Make sure to run $ yarn install to update your dependencies based on the new Node version.

This happens because your application contains a Yarn lockfile yarn.lock which does not match the dependencies in package.json. This can happen if you use npm to install or update a dependency instead of Yarn.

  • If applicable commit to Git and Deploy!

I'm new here, follow me for more solution oriented articles.

Top comments (2)

Collapse
 
Sloan, the sloth mascot
Comment deleted
Collapse
 
axelmukwena profile image
Axel Mukwena

Did you mean you use NPM instead? Because I've used yarn in this example