Friday, November 4, 2022

[FIXED] What is a sustainable method to upgrading node from old versions to latest?

Issue

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?


Solution

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.



Answered By - Jonatan Kruszewski
Answer Checked By - Gilberto Lyons (PHPFixing Admin)

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.