Why is it necessary to run 'npm install' when I already have all the dependence in node_module folder.
After running 'npm install' successfully on my machine, I want to setup same project on another machine, why do I require run 'npm install' again when I already have downloaded all the dependence in node_module folder?
npm install
extract all your dependencies from your package.json, download it and save them in your node_modules folder. You don't need to run npm install again and again if you already have installed all your dependencies locally.
When ever you installs a new dependency you run npm install <package-name> --save
and why --save
for the first time? because it adds the new installed dependency on your package.json. We never push node_modules to our git repo only the updated package.json is pushed to repo. In that case if a new person pulls your code from the repo he is only going to run npm install
and all the dependencies mentioned on your package.json will going to available on his project locally. Thats a small intro about why we use package.json hope it helps.
First of all I want to inform you 2 things:
npm install package -g
then -g will install it in global folder which can be accessed by any project. by using -g, package is not added to node_modules. Now here is answer of your problem. There might be possible that some dependencies of packages are installed as global on one machine and not on other one. This can happen as developers work on many project on same machine and might be they have installed global packages. So in this case you need to execute npm install
command.
Check the version of node in both system .
I guess that would be issue. you local system would have either higher version than the server.
May be not able to compile for higher version make sure the version are same for node in both , to reduce the comflict.
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.