NPM package as nested dependency of self
dependencies, module, node.js, npm
Solution
What about running making an js file for such a task?
var spawn = require("child_process").spawn;
spawn("npm", [ "install", "package-A" ], {
cwd: process.cwd() + "/node_modules/package-B/",
env: process.env
});
I'm not sure whether this will work, but maybe it inspire you to do more things with it ;)
Problem
I have an NPM package (package A) that compiles itself with the last stable version of itself. It does this through an intermediary Grunt task (package B) that itself depends on package A. Thus, the dependency chain is: Package A -> Package B (as `devDependency`) -> Package A (as `dependency`) However, when Package A is installed through `npm install`, NPM won't install Package A as a dependency of Package B, presumedly by design - I assume it's trying to prevent circular dependencies, even though because Package B is only a `devDependency`, it won't be installed on the child Package A anyways. What's the least-hacky/recommended way of installing the child Package A? My first solution was to just add an `postinstall` script that simply ran `cd node_modules/package-B && npm install package-A`, but this breaks because the CWD of `postinstall` isn't always the package's root directory.