0

Is it possible to install packages (/modules) from files like in 's Gemfile as done with bundle install or 's requirements file (eg: requirements.pip) as done using pip install -r commands ?

Say I have a file where three or four package names are listed.

How would I instruct npm to install packages whose names are found in that file (and resolve dependencies which it also does)?

5
  • I don't really understand the question but you can check the documentation for npm install and that might help docs.npmjs.com/cli/install Commented Jul 8, 2017 at 14:08
  • I already checked the documentation. Basically I'm asking for a direct bundle install and pip install -r alternatives if you are familiar with those languages. Commented Jul 8, 2017 at 14:09
  • So are you asking if you can use npm to read a gemfile or a python requirements file? Or are you asking if there's some equivalent to those for node? Commented Jul 8, 2017 at 14:13
  • As some answers already mention the equivalent of ruby's gemfile and python's requirement's file in is the package.json file. Every package on npm has one and the dependencies you need are listed in a field called "dependencies" which you can manually update or update by using npm install <package> --save Commented Jul 8, 2017 at 14:18
  • I am asking if it is possible to have just one package.json file to keep all the packages I need inside of it and then install all of them with a single npm install command. Commented Jul 8, 2017 at 14:22

2 Answers 2

1

Just create your package JSON, you can use yarn to manage your packages instead of npm, it's faster.

Inside your package you can create a section of scripts accessed by npm run

scripts: { customBuild: 'your sh code/ruby/script whateve' }

And after you can run on terminal, npm run customBuild for example

Sign up to request clarification or add additional context in comments.

Comments

0

you can use NPM init to create a package.json file which will store the node packages your application is dependent on, then use npm install which will install the node packages indicated in the package.json file

Comments