Depending on module with postinstall script using gulp broken on npm 3
See original GitHub issueI’m developing a node app (let’s call it foo
) that depends on another npm module (let’s call it bar
) that has "postinstall": "gulp build"
(to run babel over some es6 code). The bar
module also has a devDependency
on gulp
to make sure people can install the module even if they don’t have gulp installed globally.
When I npm install
in foo
, the installation of the bar
module fails with:
Local gulp not found in /path-to/foo/node_modules/bar
Try running: npm install gulp
This is an error message from gulp, not npm. In fact, gulp has some logic to check whether gulp is installed locally in the module depending on it (in this case, /path-to/foo/node_modules/bar/node_modules/gulp
).
Since npm 3 installs all modules flat, the gulp module ends up underneath foo, not bar, causing the gulp cli to exit with this error.
Is there any way around this?
Issue Analytics
- State:
- Created 8 years ago
- Reactions:2
- Comments:13 (5 by maintainers)
Top GitHub Comments
I just came across the same issue… I published a node module which has the following entries in
package.json
:Unfortunately people, who install my library, get an error during the
postinstall
step becausegulp
cannot be found. But I expectednpm
to find the local gulp which is declared in my library’s development dependencies:Do I need to declare
gulp
as usual dependency to usegulp build
in apostinstall
task?As of
npm@5
the scriptprepublish
is deprecated. You can useprepare
instead. Make sure to addgulp-cli
to yourdevDependencies
so that it is not required as a global module.