skip to Main Content

I have a question. please forgive my lack of knowledge since I am a beginner

when we push our code Github or anywhere else for hosting, obviously we push everything without the node_modules folder.

Then how do all the third-party libraries work in the hosted website since the node_modules folder wasn’t added and all the libraries are dependent on the node_modules folder?

I have been wondering for a lot of time now.

2

Answers


  1. When you create your production build, the needed node_modules are build into a single js file (depending on your configuration ofc), so once you’ve got the production build, that includes everything for the site to work.

    You don’t push the node_module to GIT because it’s reproducible by running eg npm install after cloning the project, no need to save such data to GIT.

    Login or Signup to reply.
  2. Every libraries that needs to be installed is included in the package.json file. Upon deploying your application, there will a build step in which the libraries will be installed by simply running npm start which installs the libraries listed in the package.json file.

    So no need to include such huge node_modules folder as it can be reproduced.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search