You might want to take a look at the documentation for npm shrinkwrap. It creates an npm-shrinkwrap.json, which will take precedence over any package.json when installing.
Basically, the equivalent is:
npm shrinkwrap
npm install
Edit:
Since v5.0.0, npm now always creates a package-lock.json, with the same format as npm-shrinkwrap.json. There have been other changes since then, not least in the latest v5.6.0. See the package-lock docs.
You install each dependency with npm install --save my-dependency and it will be added to the package.json file. So the next person on the project can install all the dependencies with npm install command on the same folder of package.json.
But in my case i wanted to install global requirements of npm via a text file (similar to pip install -r requirements.txt).
You might want to take a look at the documentation for npm shrinkwrap. It creates an
npm-shrinkwrap.json
, which will take precedence over anypackage.json
when installing.Basically, the equivalent is:
Edit:
Since v5.0.0, npm now always creates a
package-lock.json
, with the same format asnpm-shrinkwrap.json
. There have been other changes since then, not least in the latest v5.6.0. See the package-lock docs.Normally dependencies in a node project are installed via package.json: https://docs.npmjs.com/files/package.json
You install each dependency with
npm install --save my-dependency
and it will be added to the package.json file. So the next person on the project can install all the dependencies withnpm install
command on the same folder of package.json.But in my case i wanted to install global requirements of npm via a text file (similar to
pip install -r requirements.txt
).You can do that with:
cat requirements.txt | xargs npm install -g
To install npm packages globally from a text file (e.g.
npm-requirements.txt
) with a format similar to a pip requirement file:This allows comments in the requirements file, just like pip. (source)
A command similar to
pip freeze > requirements.txt
is:However, this is imperfect because it does not save the version numbers of npm packages.