3.1 KiB
3.1 KiB
All of our npm dependencies are locked via the npm-shrinkwrap.json
file for the following reasons:
- our project has lots of dependencies which update at unpredictable times, so it's important that we update them explicitly once in a while rather than implicitly when any of us runs npm install
- locked dependencies allow us to do reuse npm cache on travis, significantly speeding up our builds (by 5 minutes or more)
- locked dependencies allow us to detect when node_modules folder is out of date after a branch switch which allows us to build the project with the correct dependencies every time
We also generate npm-shrinkwrap.clean.js
file which is used during code reviews or debugging to easily review what has actually changed without extra noise.
To add a new dependency do the following:
- if you are on linux or windows, then use MacOS or ask someone with MacOS to perform the
installation. This is due to an optional
fsevents
dependency that is really required on MacOS to get good performance from file watching. - make sure you are in sync with
upstream/master
- ensure that your
node_modules
directory is not stale by runningnpm install
- add a new dependency via
npm install --save-dev <packagename>
- run
./tools/npm/reshrinkwrap
- these steps should change 3 files:
package.json
,npm-shrinkwrap.json
andnpm-shrinkwrap.clean.json
- commit changes to these three files and you are done
To update existing dependency do the following:
- if you are on linux or windows, then use MacOS or ask someone with MacOS to perform the
installation. This is due to an optional
fsevents
dependency that is really required on MacOS to get good performance from file watching. - make sure you are in sync with
upstream/master
:git fetch upstream && git rebase upstream/master
- ensure that your
node_modules
directory is not stale by runningnpm install
- run
npm install --save-dev <packagename>@<version|latest>
ornpm update <packagename>
to update to the latest version that matches version constraint inpackage.json
- run
./tools/npm/reshrinkwrap
- these steps should change 2 files:
npm-shrinkwrap.json
andnpm-shrinkwrap.clean.json
. Optionally if you usednpm install ...
in the first step,package.json
might be modified as well. - commit changes to these three files and you are done
To Remove an existing dependency do the following:
- if you are on linux or windows, then use MacOS or ask someone with MacOS to perform the
installation. This is due to an optional
fsevents
dependency that is really required on MacOS to get good performance from file watching. - make sure you are in sync with
upstream/master
:git fetch upstream && git rebase upstream/master
- ensure that your
node_modules
directory is not stale by runningnpm install
- run
npm uninstall --save-dev <packagename>@<version|latest>
- run
./tools/npm/reshrinkwrap
- these steps should change 3 files:
package.json
,npm-shrinkwrap.json
andnpm-shrinkwrap.clean.json
. - commit changes to these three files and you are done