Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

"bundle exec" style exec command #2460

wants to merge 6 commits into


None yet
10 participants

I've created a new command to execute commands using local binaries before global ones. The command auto completes based on which binaries are available in the node_modules/.bin.

npm exec jasmine-node spec
npm exec jake build

Tested under Linux (arch) and Windows 7. I don't have an OSX machine to try it out on though.

feature is totally needed

mullr commented Sep 26, 2012

+1: This largely obliviates the need for global module installs during day-to-day development, which is a good thing.

aq1018 commented Sep 29, 2012


xMartin commented Nov 2, 2012


@isaacs isaacs commented on the diff Nov 6, 2012

@@ -0,0 +1,38 @@
+module.exports = exec
+var npm = require("./npm.js")
+ , output = require("./utils/output.js")

isaacs Nov 6, 2012


utils/output.js has been removed. Either use console.log for "normal" output, or require("npmlog") for log output.

@isaacs isaacs commented on the diff Nov 6, 2012

@@ -0,0 +1,15 @@
+npm-exec(1) -- Execute command using local package bin
+ npm exec

isaacs Nov 6, 2012


Synopsis should match usage string.


isaacs commented Nov 6, 2012

+1 on the feature, but the implementation is not correct here. For example, if you depend on grunt, and it's provided by a parent package's dependencies, then you won't be able to access the grunt binaries. Also, the npm config settings provided to scripts are not being set, etc.

A better approach would be to abstract out the utils/lifecycle.js module so that it was less scripts-object oriented, but used the same logic in a DRY fashion, rather than constructing a cmd string which sets a PATH environ. (The correct way to set an environment variable is via the env hash passed to child_process.spawn; lifecycle.js does this.)

Then, lifecycle.js can call the exec function with an additional environment variable specifying the scripts-specific stuff. (Ie, the npm_lifecycle_event and npm_lifecycle_script environment vars.)

Domon commented Jan 25, 2013


glenux commented Feb 6, 2013



isaacs commented Feb 10, 2013

+1 (If the things mentioned in isaacs#2460 (comment) are fixed, of course.)

chakrit commented Mar 7, 2013

Looked at the code, not sure if I could pull this off. Any chance of this getting implemented (properly) by the core team? :p


isaacs commented Apr 29, 2013

The issue to target for this is isaacs#3313

@isaacs isaacs closed this Apr 29, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment