0

I'd like to install npm modules based on package.json

I'd like to know if there is anyway to automate installing modules.

For instance dependencies of package.json is as follows.

  "dependencies": {
    "express": "3.1.0",
    "jade": "*",
    "stylus": "*",
    "mongodb": ">= 0.9.6-7"
  }

do I have to install modules one by one like this?

npm install express@3.1.0
npm install mongodb@0.9.6 

and etc.

Any help would be appreciate.

str
  • 42,689
  • 17
  • 109
  • 127

5 Answers5

2

See the documentation about npm install.

By default, npm install will install all modules listed as dependencies in package.json.

So you can just type npm install.

str
  • 42,689
  • 17
  • 109
  • 127
  • I installed modules by npm install command. But it looks like only express is installed –  Jun 30 '16 at 09:45
  • @David What do you mean exactly by "it looks like"? `npm install` should install *all* packages from packages.json. Did you get an error message during installing? – str Jun 30 '16 at 09:47
0

when you are installing first time use --save, that module installation info will be added to package json

after that at new location you just need to run npm install

npm install express@3.1.0 --save

npm install mongodb@0.9.6 --save

npm install

also refer link

Community
  • 1
  • 1
Vinayak Shedgeri
  • 2,222
  • 1
  • 21
  • 24
0

You can do this by typing:

sudo apt-get update sudo apt-get install npm

use nvm to switch versions.

user3575353
  • 397
  • 1
  • 8
0

If you want to install a specific version of module you should use

npm install module_name@version --save

--save add's the module and the version of the module to your package.json file's dependencies. If you want to install just any version of a module you can use

npm install module_name --save

if you don't use --save at the and node would still install the last version of the module you want but it wouldn't add it to your package.json file . In this case you have some specific versions of some modules in your package.json file if you want to install them, you can simply use the

npm install

command. npm install installs all modules in your package.json file.

Also if you are new in nodeJs you can check this out. I hope this helps. Have a good day good sir.

ozata
  • 542
  • 1
  • 5
  • 16
-1

You could install modules written in package.json as follows.

npm install

Jin
  • 924
  • 1
  • 9
  • 34