Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

20
  • 284
    "I usually install most packages locally so that they get checked in along with my project code." It's usually better to make a package.json listing what npm modules you depend on and ignore the node_modules folder. Then simply npm install to get setup after you clone the repo.
    – Alex Wayne
    Commented Jan 26, 2012 at 19:20
  • 62
    In addition to package.json listing the dependencies, I like to keep known good copies of things that I depend on. Disk space is cheap and if npm or the package disappears from npm, I'll still have a fully working project in my repo.
    – Bill
    Commented Jan 26, 2012 at 20:02
  • 202
    As an old developer I nearly choked when I read the Node devs "paradigm" that "disk space is cheap". I have libraries that I am using. The idea that I might have 100 copies (or worse, NEAR copies) makes my stomach turn. Disk space is cheap, but maintenance time is expensive. Perhaps if you are doing a one-off toy project, maintenance is cheap. For real work, however, maintenance is expensive and has no bearing on the cost of disk space. Commented Jan 30, 2014 at 16:26
  • 87
    I really don't understand this last comment. Nobody is saying to have 100 copies of any piece of code, just to have 1 copy of the code that your project depends on. The alternative is to have a non-functional project if NPM or the dependency disappears one day. I would think re-writing a dependency from scratch is also pretty expensive. As an aside, I worked at Microsoft for 10 years and we always had 3rd party dependencies checked into our source tree.
    – Bill
    Commented Jun 9, 2014 at 17:32
  • 45
    @LloydSargent Having "NEAR copies" isn't worse, it's better, because each project has a specific dependency, that you've defined, and the rest of your code relies on. If you had the same versions across multiple projects then if you update anything you must update everything. Pinning dependencies allows piecemeal upgrades-substantially less maintenance. Real work, non-toy projects. Commented Aug 7, 2014 at 17:40