4

I am quite new with node.js. The feature of having my dependencies (from node_modules) in the same directory that the one of my project suits me.

I also wants to commit those dependencies with my project.

I started with a project that uses socket.io. But when I take a look at the directory generated by npm after a npm install socket.io, there are examples files, documentation, readme files, benchmark data, changelogs, ... Lots of files that I do not want to commit in my git or subversion system.

Is there an automatic tool that shrinks the content of a node_modules directory to only keep what is needed?

If I read correctly the documentation of npm, I found nothing for that. There is a prune option, but it is to remove the unused dependencies.

Vincent Hiribarren
  • 5,254
  • 2
  • 41
  • 65
  • This doesn't answer your question, but since the article you linked was written, `npm shrinkwrap` was created to take care of this issue. [Take a look at the documentation for it](http://npmjs.org/doc/shrinkwrap.html). – Michelle Tilley Jul 13 '12 at 20:18
  • 1
    Sorry, but I do not understand how it take care of this issue. According to the first paragraphe of your link, "this command locks down the versions of a package's dependencies so that you can control exactly which versions of each dependency will be used when your package is installed." I read nothing about cleaning/pruning the dependencies. – Vincent Hiribarren Jul 13 '12 at 20:24
  • The point of `npm shrinkwrap` is that it will lock the version of every dependency in your `node_modules` folder _recursively_, such that you do not need to check your `node_modules` folder into version control. It defeats the argument in "Why can’t I just use version locking to ensure that all deployments get the same dependencies?" from the blog post. – Michelle Tilley Jul 13 '12 at 20:25
  • 1
    @BrandonTilley, He wants to delete some side content in each and every module. Not lock dependencies – Pavan Kumar Sunkara Jul 13 '12 at 20:34
  • @PavanKumarSunkara I made the assumption (based on the article he linked) that the reason he's checking `node_modules` into source control is to ensure version dependencies down the tree. – Michelle Tilley Jul 13 '12 at 20:57

1 Answers1

2

No, there is not tool to do that. Generally the author of the module uses .npmignore to ignore any files which he doesn't want published. Examples, Docs, Readme, Changelogs are published by almost all authors.

The only way for you is to delete them and commit to git.

Pavan Kumar Sunkara
  • 3,025
  • 21
  • 30