+ 3
how npm works
can someone explain me the scope of what npm is really used for? is it sort of like the modules on python where you pip install a library and it will be installed on your local storage? and why is the config.json needed on each project? is it used merely as documentation or for build purposes? and if i use an npm dependancy and deploy them to a web server does that mean i have to install the dependancies again on the web server? and lastly sometimes you can save a css framework like bootstrap using npm, does that mean that css can be downloaded locally too using npm!? but i thought that it should be a node package manager. sorry if this is a bit too much questions, but this has been bothering me for some time now.
2 Respuestas
+ 3
Bro, npm is a package manager like pip or pip3 in Python.
package.json file keep track of dependency. When you install packages with npm. A folder named node_module get created. In node_module folder all your packages or dependency get stored. We always create .gitignore file to sure we don't push our dependency to github. When someone clone your repository. He/she will not have that dependency. Here package.json come into picture. package.json already have track of your dependency. To get all dependency. He/she only have to do “npm install” . It will install all the dependency.
You may ask,why we should not push node_module to github. The answer is because it will be very huge.
Sometimes, we also install dependency only required during development. In that case we do “npm install --save-dev package-name”. To deploy a node app. You should have node install on your server.
0
package.json file keeps track of dependency. When you install packages with npm. A folder named node_module gets created. In the node_module folder, all your packages or dependency get stored.