Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

npm link, not install, package.json dependencies

Tags:

node.js

npm

I want to local link all the explicit dependencies stated in my package.json.

If I just try npm link what I get is a local install of all of the packages, independently of whether or not they are already globally installed.

I didn't expect that. What I expected, and what I needed, is a behavior similar as if I'd do a npm link package. I wanted npm link to inspect the dependencies in package.json and for each of the, to create the link, and do a global install if needed.

like image 541
PA. Avatar asked Feb 22 '15 21:02

PA.


1 Answers

npm link isn't designed to work that way. There are two ways to use it, and both depend on you downloading the dependency you want to link beforehand.

First way (two steps)

cd ../dependency npm link cd ../project npm link dependency

Second way (one step)

cd project npm link ../dependency

I think what you're trying to do is npm link where the target is a globally installed package (as opposed to a globally installed link to some directory on your filesystem). npm doesn't support that.

Ref: https://docs.npmjs.com/cli/link

like image 80
Sam Mikes Avatar answered Oct 03 '22 06:10

Sam Mikes