npm link, not install, package.json dependencies
node.js, npm
Solution
After some months of waiting, I've come out with my own implementation, that I am posting here for the record.
I have two small scripts
one `packageDependencies.js` that extracts all dependencies from a `package.json`. Sschematically the code has:
fs.readFile(process.argv[2]||'package.json','utf8',(err,data)=>{
if(err) return console.error(err);
var o = JSON.parse(data);
for (var p in o.dependencies) console.log(p);
for (var p in o.devDependencies) console.log(p);
});
and another `npmlink.sh` that iterates over that list and for each package, just `npm --global install` and `npm link`. Schematically,
for d in "$(node packageDependencies.js)"; do
npm --global install $d
npm link $d
done
Problem
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.