I am about to do a large project with node.js and currently try sort a few things out.
In earlier node projects I had an extra folder for all node modules I used. This folder was ignored by git and I managed version and updates via git submodules, which was not easy (no dependencies, updating to new version was not always fun.)
What I am looking for is:
npm install packagename
npm dump_modules_into_file
So everyone else who is involved in this project could do:
npm install_or_update_modules_from_file
I don not want to have node_modules tracked by my git repository. Basically I want something similar to how symonfy2 handles it bundles.
P.S.: I know about npm submodule packagename, but this command is not very helpful because it does not install dependencies and it does not update the modules.
P.S.2: I ready about the package.json, but this also has some flaws. (No parameters and you have to update module versions by hand.)
package.jsonwill accomplish what you’re looking for. In your comment about passing the--mongodb:nativeflag, that flag is an argument to thenpmcommand and does work when using apackage.jsonin your own project. The mongodb package has an “install script” which looks for that flag in the node processing environment. If that flag is present, then it spawns another process for the build. So, if you have mongodb as a dependency in your package.jsonRunning
npm install --mongodb:nativewill work.With regards to “updating it by hand” – it’s really only the first time that it might take a while, and I’m sure you could write a script to generate it if there are a lot of dependencies. However, it sounds like you have a fairly large team, and if that is the case, then automating the updates to
package.jsonwill turn really ugly (think new developers, experimental features, etc.) Having accountability for broken builds in this part of the development cycle isn’t necessarily a bad idea.References:
EDIT: and as Nick mentioned, adding the ‘node_modules’ directory to
.gitignorewill prevent any of those files from being checked into your repo