Roots Discourse

How to fix error, "The engine 'node' is incompatible with this module." when deploying

Hi, we’re using DeployBot to deploy updates to a Sage WordPress project: https://tobaccoatlas.org/

Our deploy script seems to run fine until the build process at the end where I get this error:

error sage@9.0.0-beta.4: The engine "node" is incompatible with this module. Expected version ">= 6.9.4". Got "6.9.2"

I’m using the default environment settings in deployBot:

Ubuntu 16.04 - PHP 7, NodeJS 6.x, Grunt, Gulp, Sass, Go, Java 7/8, RVM, Python (default)

and I see this in our packages.json file:

"engines": {
    "node": ">= 6.9.4"
  },

All of which seem to allow for that Node version 6.9.4 as they should. Can anyone shed some light on what might be at issue here? I’m not too familiar with this process so any advice is appreciated.

/Chris

Hey @Chris_H - it looks like the version it’s trying to use is actually 6.9.2, not 6.9.4, which is why it doesn’t meet the requirement specified. Perhaps their container only installs 6.9.2? In that case, you would need to modify your container setup to install a newer version of node.

You’d do that by adding this to your container’s build commands:

curl -sL https://deb.nodesource.com/setup_6.x | bash -
apt-get install -y nodejs

If that doesn’t fetch a new enough version of the 6.x branch for some reason, you can hop up to 8.x by changing the 6 in the URL above to an 8 (that’s what I have for my Sage 8 and Sage 9 containers).

Thanks very much, thanks so helpful.

The build script we have now looks like this:

apt-get update
apt-get -y install php7.0-mbstring
apt-get purge php7.0-gd
apt-get -y install php7.0-gd
apt-get -y install zip unzip php7.0-zip
phpenmod php7.0-mbstring
phpenmod php7.0-gd
phpenmod gd, zip, unzip, php7.0-zip
restart php7.0-fpm
curl -sS https://getcomposer.org/installer | php
mv composer.phar /usr/local/bin/composer
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list
apt-get update
apt-get install yarn
composer install --no-dev
npm i
yarn
yarn run update:submodules
yarn run build:production

Should I insert those lines in a certain spot? I’m thinking directly above the npm i line?

Correct me if I’m wrong, but don’t these commands perform the same function? I’m curious why you’ve got the overhead of installing and running yarn if you’re going to use npm.

Yeah, I really don’t know. Someone else actually wrote these commands and I don’t know enough to change them. My understanding is that they are similar but not exactly the same so I didn’t want to mess with them. Are they likely doing the same thing?

As for the Node version, I added those lines directly above the npm i and the script ran successfully. Thanks again @mmirus!

1 Like

So far as I know they’re identical: They install dependencies from your package.json. I’ve used them interchangeably many times. I’m not an expert on the differences between yarn and npm, but for what your script appears to be doing (install dependencies, run two scripts) I don’t think you’d even need yarn; npm can do both of those things.

Good to know, thanks!