Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

npm equivalent of `pip install -r requirements.txt`

Tags:

npm

pip

What are the npm equivalent of:

pip freeze > requirements.txt pip install -r requirements.txt 
like image 467
Ron Avatar asked Aug 07 '12 06:08

Ron


People also ask

Can pip install 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.

What can I use instead of pip install?

npm, Homebrew, Yarn, RequireJS, and Bower are the most popular alternatives and competitors to pip.

Is npm same as 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.

What is Requirements txt in pip?

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).


2 Answers

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

like image 189
Guilherme D Heynemann Bruzzi Avatar answered Sep 20 '22 08:09

Guilherme D Heynemann Bruzzi


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.

like image 40
Linus Thiel Avatar answered Sep 20 '22 08:09

Linus Thiel