site icon

Hi, I’m Chris

I am a web developer teaching
regular people how to code

~ Welcome to my blog ~

How to revert back to an older NPM package version

After updating a NPM package, sometimes we can discover the updated version can cause an unexpected bug in our projects.

If we are sure it was working before the update, reverting back to the older version may be a good choice until the issues have been resolved.

Taking a random NPM package, we install in the terminal like this:

// using npm
npm i jsonwebtoken

// using yarn
yarn add jsonwebtoken

At the time of writing, this would install the jsonwebtoken package at the latest version of 8.5.1.

To change back to an earlier version, all we need to do, is to re-install the package, specifying the version number:

// using npm
npm i jsonwebtoken@8.4.2

// using yarn
yarn add jsonwebtoken@8.4.2

Which then sets our package back to the earlier version of 8.4.2.

This also works for global packages too using the -g flag.

- By Chris Dixon

Chris Dixon is a web developer and teacher. Teaching thousands of students mainly in Vue.js React.js, WordPress and web development.