Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Deploying Rails App via Heroku uses an old version of Node

While trying to deploy my Rails app via Heroku "git push heroku master" on my Ubuntu 16.04 machine, I receive the following error:

[2/4] Fetching packages...
remote:          error @rails/[email protected]: The engine "node" is incompatible with this module. Expected version ">=8.16.0".
remote:        error An unexpected error occurred: "Found incompatible module".
remote:        info If you think this is a bug, please open a bug report with the information provided in "/tmp/build_c472d4366cfa53133fe29a2426a45a7b/yarn-error.log".
remote:        info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
remote:
remote:  !
remote:  !     Precompiling assets failed.
remote:  !
remote:  !     Push rejected, failed to compile Ruby app.
remote:
remote:  !     Push failed

This is my package.json file (in root folder):

{
  "name": "site",
  "private": true,
  "dependencies": {
    "@rails/webpacker": "4.2.2",
    "flatpickr": "^4.6.3",
    "jquery": "^3.3.1",
    "node": "^12.x",
    "node-sass": "^4.13.1",
    "reading-time": "^1.2.0",
    "simple-lightbox": "^2.1.0"
  },
  "devDependencies": {
    "@babel/plugin-syntax-dynamic-import": "^7.8.3",
    "webpack-cli": "^3.3.11",
    "webpack-dev-server": "^3.10.3"
  }
}

node --version:

v13.10.1

heroku run node --version:

Running node --version on ⬢ -site... up, run.4229 (Hobby)
v12.16.1
like image 256
Cepheaus C Avatar asked Nov 05 '25 02:11

Cepheaus C


2 Answers

https://devcenter.heroku.com/articles/deploying-nodejs

You can specify a node version on Heroku via your package.json

{
  "name": "node-example",
  "version": "1.0.0",
  "description": "This example is so cool.",
  "main": "web.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [
    "example",
    "heroku"
  ],
  "author": "jane-doe",
  "license": "MIT",
  "dependencies": {
    "express": "^4.9.8"
  },
  "engines": {
    "node": "10.x"
  }
}

You can find the currently supported node versions here: https://devcenter.heroku.com/articles/nodejs-support

like image 124
Tin Nguyen Avatar answered Nov 06 '25 21:11

Tin Nguyen


Not sure exactly what it is, but the issue had something to do with the Heroku buildpack I was using (heroku-buildpack-bundler2)

Here's what I did to solve it:

$ heroku buildpacks:set heroku/ruby
$ heroku buildpacks:add --index 1 heroku/nodejs

$ git push heroku master

All works fine now :-)

like image 36
Cepheaus C Avatar answered Nov 06 '25 21:11

Cepheaus C



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!