Click here to Skip to main content
15,894,362 members
Articles / Web Development / Node.js
Tip/Trick

How to install node modules nested with npm@3, as npm@2 did

Rate me:
Please Sign up or sign in to vote.
1.00/5 (1 vote)
31 Jan 2016CPOL 10.6K   1   1
Using the --legacy-building flag

Introduction

Managing packages with npm (a.k.a. nod package manager) recently experienced some major changes.
While npm version 2 stored dependent packages in a deeply nested folder tree, version 3 will flatten the dependency folder structure as much as possible.

In general, I am a great fan of this new behavior. For some special cases there may be a reason to stick with the older structure, at least for some time. E.g. for some existing packages may still rely on the nested structure.

Using the code

A rather straight froward approach is already implemented in npm@3, but it is well hidden somewhere in the backrooms of documentation [^]. A google search today brought up some unconventional and impractical ideas. So I wanted to share this hint with you:

Using the --legacy-bundling flag will install packages in the well-known deeply nested structure.

npm install --legacy-bundling

This stops any flattening or deduping functionality.

If you happen to have trouble with legacy packages, probalby this can help you. If not, just please ignore this tip and enjoy the flattened, deduped node modules structure ;)

History

Keep a running update of any changes or improvements you've made here.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Germany Germany
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
Praisethanks Pin
Member 123007801-Feb-16 7:40
Member 123007801-Feb-16 7:40 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.