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.)
A light weight interface for running git commands in any node.js application. Installation – Easiest through npm: npm install simple-git Dependencies – Requires git to be installed and that it can be called using the command git. const simpleGit = require (‘simple-git’) (workingDirPath);
Installation – Easiest through npm: npm install simple-git Dependencies – Requires git to be installed and that it can be called using the command git. const simpleGit = require (‘simple-git’) (workingDirPath); where the workingDirPath is optional, defaulting to the current directory.
With libraries like browserify, Node.js also begins to blur the line between server-side development and developing for the browser. These reasons, along with many others (such as the vibrant open-source community, driven by npm), make Node.js a great technology choice for the Web.
Once the code is pushed, you can open the GitHub pages and click on “Action”, then click on the “New Workflow” button as in the next image. This will ask what template use, in our case we will choose the node.js one, but this won't exclude do access to all other action available. Now we are ready for setting up the workflow!
package.json
will accomplish what you're looking for. In your comment about passing the --mongodb:native
flag, that flag is an argument to the npm
command and does work when using a package.json
in 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.json
{
"name": "MyProject"
, "description": "Test"
, "version": "0.0.1"
, "dependencies": {
"mongodb": "*"
}
}
Running npm install --mongodb:native
will 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.json
will 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 .gitignore
will prevent any of those files from being checked into your repo
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