(gulp) Use global package when local package dependency is same?

226 views
Skip to first unread message

Jari Pennanen

unread,
Jun 20, 2014, 6:49:33 PM6/20/14
to nod...@googlegroups.com
Hello,

I haven't used nodejs a lot, but first thing I noticed when using gulp is that it requires local installation for all projects. I understand, it's good to have same version of gulp as dependency for project, so that other people using gulp on the project use same version.

But if my project has gulp as dependency to latest version, and I have globally installed latest version, why it still requires local version?

The point is, the dependency for specific gulp version should be *required*, and if it's met (using global package) why is local installation required?

I hope I am being clear.

Thanks.


Gary Katsevman

unread,
Jun 21, 2014, 3:11:40 PM6/21/14
to nod...@googlegroups.com

I believe the global install is only so that you have the gulp cli command available. All the actual tasks and what not are installed locally and the global gulp just finds the appropriate local tasks and runs them.


Gary Katsevman
gkatsev.com


--
Job board: http://jobs.nodejs.org/
New group rules: https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
---
You received this message because you are subscribed to the Google Groups "nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+un...@googlegroups.com.
To post to this group, send email to nod...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/nodejs/eec6ce58-3a72-44a3-9368-53f817b10170%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Lee Cookson

unread,
Jun 24, 2014, 10:57:28 AM6/24/14
to nod...@googlegroups.com, m...@gkatsev.com
If you use an npm script to run gulp, and you make your verison of gulp a devDependency, npm will add ./node_modules/.bin to the path and run your local copy.

When you use a package as a dependency that has a "bin" script(s), they are sym-linked into ./node_modules/.bin for this kind of use case.

node_modules/.bin/gulp -> node_modules/gulp/bin/gulp.js

If you set up a script like this in package.json:

scripts: {
   build: "gulp"
}

This command runs your copy of gulp on your package:

npm run build

There are lots of uses, like defining a prepublish script to test/validate before publishing a package to the registry.

Reply all
Reply to author
Forward
0 new messages