简体   繁体   中英

Npm install keeps on showing on other device as soon as a dependency is installed

My problem is that whenever I install any dependency using npm install --save then the dependency gets installed but, after I push my code on git and someone else pulls the code, he faces the issue that dependency is missing. Then that person needs to do npm install again to install the dependency. How to solve this? What command should I run so that the dependency is added automatically to the other persons desktop?

You could do that, but you should not be doing that. IF u want to do that then all what you have to do is to track the node_modules folder from git, however again this is extremely not recommended .

The normal flow is to do what you exactly did, you declare the packages, and later anyone that wants to work on the project, they have to reinstall them.

There are many reasons that the normal flow is like what you described, and that it is not recommended to push node_modules to git, here are some of them:

  • pushing these modules will make the repo size extremely large
  • pushing these modules will make working between different people harder, because each update will cause conflicts in files you do not own
  • pushing these might make your project not work across different operating systems, some packages when installed have os specific code
  • pushing these will make it later hard to integrate with many automatic tools like ci/cd flows/ static linets, and many other tools

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM