-
Notifications
You must be signed in to change notification settings - Fork 0
Updating Project Node Dependencies
- Open Command Prompt or Windows PowerShell in the root directory of the repository and run
cd .\apps\frontend
- Run the command
npm outdated
- Output should look similar to this:
The yellow highlighted dependencies indicate new major versions (usually has breaking changes), and the red highlighted dependencies indicate minor updates.
- Run the command
npm update
, this will update all of the red highlighted dependencies to the “wanted” level of versioning. - Running npm outdated again should display only yellow highlighted dependencies now.
Upgrading major versions is more involved than upgrading minor version numbers.
- Run
npm -v
and ensure that the version number displayed is at least6.9.0
. Then, runnode -v
and ensure the version number displayed is at least10.16.0
. - 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>
, replacingpackage_name_alias
with a name for the new version, andpackage_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
You should get a similar output to the example output below if the alias install worked correctly.
- Now, use the VSCode search tab to find where the dependency to update is being used.
- For each usage, comment out the original import, and add a new import that uses the new package alias we downloaded earlier.
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.
-
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.
-
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.
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.
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 thenvm
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