Skip to main content

Upgrading NodeJS to latest on macOS

ยท One min read

Working on a project today, I updated package.json to update some dependencies. After that, running npm i to refresh the npm packages got errors like the following.

npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE package: '[email protected]',
npm WARN EBADENGINE required: { node: '^18.17 || >=20.6.1' },
npm WARN EBADENGINE current: { node: 'v18.14.0', npm: '9.3.1' }
npm WARN EBADENGINE }

Usual issues when working on open source packages is that one depends on another, and when one needs to be upgraded, the other must be updated. However, this time, we need to do the upgrade of NodeJS to a supported version.

At first, I thought of downloading the new PKG installer from nodejs.og. But then after some Google, found the following simple approach to upgrade the NodeJS to latest.

sudo npm cache clean -f 
sudo npm install -g n
sudo n stable

While stable in n stable command can be replaced with other keywords like latest, lts or specific versions like 18.17.1. It's really easy and simple.

You can visit https://www.npmjs.com/package/n to find out a bit more about what can be done with n command.