I need to know if the following behavior is normal.
When I npm install
, each package from my package.json and the dependencies, don't get installed nested anymore, but each dependency is installed in the node_modules
directory. That makes my node_modules
directory blown and look like this:
This happened since I updated npm and node.
Now I run:
npm -v 3.3.6
node -v 4.2.1
python 2.7
windows 7
wamp
My package.json
file looks like this:
{
"private": true,
"devDependencies": {
"gulp": "^3.8.8"
},
"dependencies": {
"laravel-elixir": "^3.0.0",
"bootstrap-sass": "^3.0.0"
}
}
It's the standard laravel package.json
file.
Is there a way to have nested directories again, because I don't like such a blown article with over 100 sub directories.
By default, npm install will install all modules listed as dependencies in package.
If you're using npm : Run npm dedupe after installing packages to remove nested duplicates. You can try deleting your package-lock. json and do a fresh install.
to install the dependencies automatically , first of all list them manually in package. json file and run the npm install (sometimes sudo npm install ) command.
Update: As Erik Pukinskis mentioned in the comments:
As of npm 3.5, support for --legacy-bundling
has been dropped.
Yes, there is a way to have nested directories again by changing npm's (version 3 as of this writing) default behaviour:
Delete the currently present node_modules
folder.
Tell npm to install with legacy bundling for this one install:
npm install --legacy-bundling
A "permanent" alternative:
Set your npm config to always use legacy bundling...
npm set legacy-bundling=true
.. and run as usual:
npm install
Note: fetching dependencies with legacy bundling will take a lot more time because many several different versions of the same dependencies will be installed.
Disclaimer: As a non-Windows user I have no need for flat dependencies and want to find self-declared dependencies with ease in favour of automatic deduping. Since installing npm dependencies without legacy bundling already takes an incredible amount of time I'm usually willing to spend those extra minutes install time. It gets back down to 5 directories from previously 700+ (...) in a Laravel Elixir setup with bootstrap (non-sass), font-awesome and jquery added.
That's the new behavior of npm 3
as per this npm blog.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With