user6112430
user6112430

Reputation:

Node install npm modules

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 [email protected]
npm install [email protected] 

and etc.

Any help would be appreciate.

Upvotes: 0

Views: 2652

Answers (5)

ozata
ozata

Reputation: 562

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.

Upvotes: 0

user3575353
user3575353

Reputation: 397

You can do this by typing:

sudo apt-get update sudo apt-get install npm

use nvm to switch versions.

Upvotes: 0

Vinayak Shedgeri
Vinayak Shedgeri

Reputation: 2402

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 [email protected] --save

npm install [email protected] --save

npm install

also refer link

Upvotes: 0

Jin
Jin

Reputation: 932

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

npm install

Upvotes: -1

str
str

Reputation: 45019

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.

Upvotes: 2

Related Questions