Why npm installed lots of unexpected modules?

2019-08-26 02:45发布

问题:

I'm using laravel-5.1,with this package.json { "private": true, "devDependencies": { "gulp": "^3.8.8" }, "dependencies": { "laravel-elixir": "^4.0.0", "bootstrap-sass": "^3.0.0" } }

under root directory,I use npm install command under project root to install laravel-elixir and bootstrap-sass.
After npm installation finished, I found there were more than 30 node modules under my node_modules diretory,and lots of .cmd files under project root!
Now I have used git to rollback my project,how to install laravel-elixir and bootstrap-sass correctly using npm?

回答1:

Because each dependency may depend it self on other dependencies and so one.

For example if you want to install a single dependency you may end up with 10 or more dependencies.

Another example is when you install bootstrap you end up with jQuery installed also because Bootstrap depends on jQuery.



回答2:

These dependencies might require other dependencies, so it will install them aswell.