FAQ - nodenv/nodenv GitHub Wiki
nodenv (being forked from rbenv) uses node-build to install new versions of node. node-build (being forked from ruby-build) bundles the build definition files for the versions of node it can install (for reasons). This means you need to keep node-build up to date to install recent versions of node. (At least until nodenv/node-build#145 is completed.) Accordingly, how you update node-build depends on how it was installed:
- homebrew:
brew update && brew upgrade nodenv node-build
- git:
git pull origin master
(or appropriate remote name)
Other options:
- use the nodenv-update plugin:
nodenv update
- scrape your own build definitions with node-build-update-defs plugin:
nodenv update-version-defs
"The program 'node' is currently not installed"
"node: command not found"
This indicates that either nodenv isn't running or the shims aren't in PATH
. Per https://github.com/nodenv/nodenv#installation there are 2 essential steps:
- nodenv itself must be in
PATH
- nodenv's shims must be in
PATH
#2 can be done for you automatically by adding eval "$(nodenv init -)"
to your ~/.bashrc
as instructed by the output of nodenv init
nodenv keeps shims around in two cases:
- The executable is still present in any Node version. Check with
nodenv whence <shim>
- The shim was kept around by a plugin. Check your list of plugins:
nodenv hooks rehash
Typically this is as easy as ls -al $(nodenv root)/versions/*/bin
and you'll find the offending bin still lives in one of your node versions. Remove it and then nodenv rehash
.
npm WARN lifecycle The node binary used for scripts is /Users/$USERNAME/.nodenv/shims/node but npm is using /usr/local/Cellar/node/10.10.0/bin/node itself.
Use the `--scripts-prepend-node-path` option to include the path for the node binary npm was executed with.
npm config set scripts-prepend-node-path auto
As the docs state, this feature of npm is about whether the current node executable matches the one that invoked npm. nodenv uses a shim to determine which executable to use. Thus, the node executable first in the path for any npm scripts is nodenv's shim. If you currently don't have a node version selected by nodenv, then the node executable that is running npm is your system
node (typically one installed separately from nodenv, like through homebrew or your OS). ergo, mismatch
https://docs.npmjs.com/misc/config#scripts-prepend-node-path
The options for this setting are:
-
false
never prepend the "actual" node executable toPATH
-
true
always prepend the "actual" node executable toPATH
-
auto
only prepend the "actual" node executable toPATH
if mismatch -
warn-only
same as false, but issue the annoying warning message if mismatch
Any of the options besides warn-only
will work to silence the message.
false
is safe to use if you are confident that npm and node will both run through the nodenv shims and resolve to your system
node. This is a safe assumption if using a recommended installation of nodenv where nodenv's shims are first in PATH
.
true
is safe to use if you're okay with the fact that any node invocation from your scripts will bypass nodenv and will use the node executable resolved by npm. This should also be fine since the one the npm resolves to should always be the same node that nodenv would have resolved to. (Remember, nodenv's npm and node shims both resolve to the same node installation.)
auto
is really just the same as true
, but should only need to prepend the PATH whenever you don't have a nodenv version selected.
Personally, I recommend auto
. The only time I can imagine where this configuration option isn't safe is if, somehow, you invoke an npm executable that isn't nodenv's shim, but the node first in PATH is nodenv's shim.
Common errors running npm scripts through WebStorm or other JetBrains products:
Cannot resolve 'npm' package manager
Please specify npm or yarn package: cannot find "bin/npm-cli.js" inside "___" directory
This is because JetBrains' npm integration is broken. Rather than invoking the npm (or yarn) executable that exists in PATH
, they presume that there is a bin/npm-cli.js
script relative to the npm package directory. Of course, with shims this is not the case.
Despite a lot of discussions on JetBrains' support forum and on stack overflow, the issue is not a PATH
issue. Ensuring that WebStorm is running with the proper PATH
(via .profile/.bash_profile tweaks, or .plist hacks) will not resolve the problem.
Use the @nodenv/jetbrains-npm package. https://github.com/nodenv/jetbrains-npm