Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/npm.js
diff options
context:
space:
mode:
authorisaacs <i@izs.me>2010-12-13 06:35:46 +0300
committerisaacs <i@izs.me>2010-12-13 07:45:34 +0300
commit19250e7aed5d0f8c85bbd8116e43ed1265b8eeab (patch)
treeabdc65847090e03e6b5a814d22bec5d28e0be5ea /npm.js
parent72ccb2ee43bc8927c2bcf0c8902676c581385dd8 (diff)
Use effective location of node as execPath.
Do the `which`-style execp lookup for something matching argv[0] if it's not absolute, and then use THAT as the effective execPath instead of the *actual* execPath. This should provide some ways to work around odd situations that arise when node is installed with other package managers, particularly Homebrew.
Diffstat (limited to 'npm.js')
-rw-r--r--npm.js13
1 files changed, 10 insertions, 3 deletions
diff --git a/npm.js b/npm.js
index 3ee18acae..1dabd4a10 100644
--- a/npm.js
+++ b/npm.js
@@ -20,6 +20,7 @@ var EventEmitter = require("events").EventEmitter
, path = require("path")
, mkdir = require("./lib/utils/mkdir-p")
, abbrev = require("./lib/utils/abbrev")
+ , which = require("./lib/utils/which")
npm.commands = {}
npm.ELIFECYCLE = {}
@@ -118,9 +119,15 @@ npm.load = function (conf, cb_) {
if (loaded) return cb()
loaded = true
log.waitForConfig()
- ini.resolveConfigs(conf, function (er) {
- if (er) return cb(er)
- mkdir(npm.tmp, cb)
+ which(process.argv[0], function (er, node) {
+ if (!er && node !== process.execPath) {
+ log.verbose("node symlink", node)
+ process.execPath = node
+ }
+ ini.resolveConfigs(conf, function (er) {
+ if (er) return cb(er)
+ mkdir(npm.tmp, cb)
+ })
})
}