Reputation: 41
Someday I just got curious about node_module
in framework or UI libraries such as React. After searching some stuff, I found there should be no changes in node_modules
unless the user really needs to, so here's my questions.
node_modules
?node_modules
there were no changes. (I thought it should show an error, but it worked Ok...)npm start
in React), does NPM downloads the external files for example from Github everytime and places in the DOM? If that's right, the files in node_modules
are just readable ones?Could someone give me an answer?
Upvotes: 1
Views: 1455
Reputation: 134
node_modules
are the libraries / packages / modules (whatever name you call) written by the open source community. They can be inter-depending. If you change one of those files without reviewing the impact to their dependent, the execution of code may crash.
However, not every single file or every single line of codes are required for each execution of code. Most of the time, one package can do things way more than what your code truly needed. If your code doesn't depend on the files that you changed, your project can still run happily.
npm start
doesn't download files automatically. npm install
does. So files in node_modules
are not readable only. However, in many case, files in node_modules
were ignored from git commit
. In server environment, packages are freshly pulled from remote, instead of from your local machine. Therefore your changes to packages would not be deployed unless you explicitly do so.
Technically you can modify the files in node_modules
and NOT running npm update
forever - not a good commercial practice. Acceptable for personal project, if you are the sole programmer and can fully control when to update packages.
Upvotes: 3
Reputation: 555
Upvotes: 1