Azevedo
Azevedo

Reputation: 2189

npm: How to install all dependencies from package.json globally?

I'm trying to install all dependencies inside package.json for a project using:

npm install -g

The installation is done in the project folder. Now, how do I install all dependencies globally?

Do I have to npm install <package_name> -g for every package or there is a command that will install them automatically?

Upvotes: 0

Views: 3484

Answers (2)

Wes Dean
Wes Dean

Reputation: 51

@Azevedo are you looking for something like this:

jq -r '.dependencies | keys[] as $k | "\($k)@\(.[$k])"' < ~/package.json  | xargs npm install -g 

?

Upvotes: 0

Dan Starns
Dan Starns

Reputation: 3815

you can provide a list of packages to npm install npm install <package_name> <package_name> -g for example, npm install package1 package2 -g

Upvotes: 0

Related Questions