1

I would like to upgrade a few projects from Node 8 to the latest Node version.

Amazon mentioned that Node 12 is now deprecated.

I assume there is much more to consider than simply upgrading the package version, considering these projects would have many packages installed and there could be breaking changes.

What is the approach I should take in upgrading them to the latest Node version without breaking existing functionality?

Oliver Kucharzewski
  • 2,523
  • 4
  • 27
  • 51
  • 2
    Have a rock solid test suite. – Matt Aug 18 '22 at 06:19
  • 1
    And updating semi regularly is much easier than waiting for big jumps. The overwhelming changes can often hide the little things you pick up on minor updates. – Matt Aug 18 '22 at 06:21

2 Answers2

1

Updating

It depends on how are you running Node. If it is inside a docker container, you may update the image definition in your docker.compose file:

(note: I am using 16 as demo here)

# specify the node base image with your desired version node:<version>
FROM node:16

If you have it deployed as a Node project, you can set the engines field in your package.json:

"engines" : { 
    "node" : ">=16.0.0"
}

Lastly, if we are speaking about your local computer, you can uninstall Node and re-install the wanted version or use a version manager, like nvm.

Updating locally with nvm:

nvm install 16.0.0
nvm use 16.0.0

Considerations

Make sure everything works and that your dependencies can run in the new environment. A robust test suite and a proper CD/CI pipeline are essential to guarantee appropriate functioning.

Jonatan Kruszewski
  • 1,027
  • 3
  • 23
0
$ yarn global add n
$ n latest

or

$ npm install -g add n
$ n 18

n allows you to manage several node versions with ease, i've been using it for years

André Alçada Padez
  • 10,987
  • 24
  • 67
  • 120
  • 1
    Does `n` do anything with dependencies or is this in the `nodenv`/`nvm` versioning space? – Matt Aug 18 '22 at 06:12
  • I realize my answer was out of context. N is just a nove version manager like nvm but much simpler to work with – André Alçada Padez Aug 18 '22 at 11:35
  • I was just checking as I hadn't heard of it before and thought it might have some extra features to check out. Thanks for the clarification – Matt Aug 18 '22 at 23:50