4👍
✅
Different branches may contain different content for the package.json
, either more/less dependencies or another version for the same ones. Therefore, when checking another branch is important to run npm install
to make sure the required dependencies are installed on your local environment. In case that no change is detected the output of install command will return that nothing has been changed. The IDE may even help you out and suggest to run it only when needed as it is the case for WebStorm. To consider:
- Check
package.json
andpackage-lock.json
into Git but notnode_modules
(it’s huge!) - When adding a dependency make sure to
git commit
all the changes to these two files - Whenever a branch is changed run
npm install
to make sure dependency requirements are met
Source:stackexchange.com