What are the npm equivalent of:
pip freeze > requirements.txt pip install -r requirements.txt
txt. If you are managing Python packages (libraries) with pip, you can use the configuration file requirements. txt to install the specified packages with the specified version.
npm, Homebrew, Yarn, RequireJS, and Bower are the most popular alternatives and competitors to pip.
npm is the command-line interface to the npm ecosystem. It is battle-tested, surprisingly flexible, and used by hundreds of thousands of JavaScript developers every day. On the other hand, pip is detailed as "A package installer for Python". It is the package installer for Python.
Requirements files serve as a list of items to be installed by pip, when using pip install. Files that use this format are often called “pip requirements. txt files”, since requirements. txt is usually what these files are named (although, that is not a requirement).
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 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 can do that with:
cat requirements.txt | xargs npm install -g
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.
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