Skip to content

Updating Project Node Dependencies

Rob B edited this page Sep 7, 2023 · 3 revisions

Updating Project Node Dependencies

Updating Minor Versions (x.x.1 to x.x.2)

  1. Open Command Prompt or Windows PowerShell in the root directory of the repository and run cd .\apps\frontend
  2. Run the command npm outdated
  3. Output should look similar to this:

image

The yellow highlighted dependencies indicate new major versions (usually has breaking changes), and the red highlighted dependencies indicate minor updates.

  1. Run the command npm update, this will update all of the red highlighted dependencies to the “wanted” level of versioning.
  2. Running npm outdated again should display only yellow highlighted dependencies now.

image


Updating Major Versions (1.x.x -> 2.x.x)

Single Package Dependencies

Upgrading major versions is more involved than upgrading minor version numbers.

  1. Run npm -v and ensure that the version number displayed is at least 6.9.0. Then, run node -v and ensure the version number displayed is at least 10.16.0.
  2. We are now going to install the new package version under a new alias such that we have two versions of the same package installed at the same time. Run the command npm install <package_name_alias>@npm:<package_name>, replacing package_name_alias with a name for the new version, and package_name with the name of the package to install.

In this example below, @mantine/dropzone-latest is the alias, and the package downloaded is @mantine/dropzone

image

You should get a similar output to the example output below if the alias install worked correctly.

image

  1. Now, use the VSCode search tab to find where the dependency to update is being used.

image

  1. For each usage, comment out the original import, and add a new import that uses the new package alias we downloaded earlier.

image

If there are multiple usages of the package you are updating, only change one import at a time!! This will make it easier to debug the changes between versions, if there are any.

  1. Once all usages point to the updated version of the package, go into apps/frontend/package.json and change the version of the old package to the new version.

  2. Delete the alias version as well, and then go back and make all of the import statements point to the original package (uncomment the other code and delete the alias import). If any imports were added/changed due to the version upgrade, be sure to mirror those changes to the import statement that points to the original package.


Multiple Package Dependencies

Sometimes, packages are modular and are spread out between multiple packages so that you can opt-in to the ones you need. Unfortunately, because these packages have cross-dependencies, they can’t be internally referenced via aliases. To update these types of dependencies, you have to upgrade the original packages all at once. Change the package version numbers in package.json to the latest one, and fix the bugs that pop up all at once.

Updating Node Itself

If you want to update the version of Node.js used by the project, you will need to do the following

  • Make sure that the project's node dependencies will still work under that version of Node.js (or just perform the update and see what breaks)
  • Modify /setup/variables.sh to contain the right version and run the dev install script again. If the nvm commands fail for some reason, try downloading an updated version of node version manager.
  • Modify /apps/frontend/frontend.Dockerfile to use the Node base docker image of the right version
  • Modify the /.github/workflows/node-test.yml node-version matrix field to the right version (or you'll get) this error