I'm having a problem with npm and node, using the fish shell, following a recent update of fish, fisher, bass and nvm on OS X Big Sur.
$ node -v
type: Invalid combination of options
Fish nvm: 'node' is currently not installed, try running npm i -g node
$ npm -v
type: Invalid combination of options
Fish nvm: 'npm' is currently not installed, try running npm i -g npm
NVM seems to be working fine:
$ nvm list
-> v10.16.0
v12.4.0
v12.16.1
v13.11.0
v14.16.0
system
default -> 10.16.0 (-> v10.16.0)
iojs -> N/A (default)
unstable -> N/A (default)
node -> stable (-> v14.16.0) (default)
stable -> 14.16 (-> v14.16.0) (default)
lts/* -> lts/fermium (-> v14.16.0)
lts/argon -> v4.9.1 (-> N/A)
lts/boron -> v6.17.1 (-> N/A)
lts/carbon -> v8.17.0 (-> N/A)
lts/dubnium -> v10.24.0 (-> N/A)
lts/erbium -> v12.21.0 (-> N/A)
lts/fermium -> v14.16.0
It successfully switches node versions.
$ nvm use v14
Now using node v14.16.0 (npm v6.14.11)
$ which node
/Users/brianfogel/.nvm/versions/node/v14.16.0/bin/node
$ which npm
/Users/brianfogel/.nvm/versions/node/v14.16.0/bin/npm
For additional context here are some other things that might be helpful to show:
$ fish --version
fish, version 3.2.0
$ fisher --version
fisher, version 4.2.0
$ nvm -v
0.37.2
$ cat ~/.config/fish/functions/node.fish
function node -d "Server-side JavaScript runtime" -w node
__nvm_run "node" $argv
end
$ cat ~/.config/fish/functions/npm.fish
function npm -d "node package manager" -w npm
__nvm_run "npm" $argv
end
$ cat ~/.config/fish/functions/nvm.fish
function nvm
if not type -q bass
echo 'Bass is not installed please install it running fisher edc/bass'
return
end
set -q NVM_DIR; or set -gx NVM_DIR ~/.nvm
set -q nvm_prefix; or set -gx nvm_prefix $NVM_DIR
bass source $nvm_prefix/nvm.sh --no-use ';' nvm $argv
set bstatus $status
if test $bstatus -gt 0
return $bstatus
end
if test (count $argv) -lt 1
return 0
end
if test $argv[1] = "use"; or test $argv[1] = "install"
set -g NVM_HAS_RUN 1
end
end
$ cat /usr/local/bin/node
#! /usr/bin/env fish
__nvm_run "node" $argv
$ cat /usr/local/bin/npm
#!/usr/bin/env fish
__nvm_run "npm" $argv
$ $ set --show fish_user_paths
$fish_user_paths: set in global scope, unexported, with 10 elements
$fish_user_paths[1]: |/Users/brianfogel/.pub-cache/bin|
$fish_user_paths[2]: |/Users/brianfogel/flutter/flutter/.pub-cache/bin|
$fish_user_paths[3]: |/Users/brianfogel/flutter/flutter/bin|
$fish_user_paths[4]: |/usr/local/sbin|
$fish_user_paths[5]: |/Applications/Postgres.app/Contents/Versions/latest/bin|
$fish_user_paths[6]: |/Users/brianfogel/.npm-global/bin|
$fish_user_paths[7]: |/usr/local/Cellar/php/7.3.4_1/bin|
$fish_user_paths[8]: |/usr/local/sbin|
$fish_user_paths[9]: |/Applications/Postgres.app/Contents/Versions/latest/bin|
$fish_user_paths[10]: |/Users/brianfogel/.yarn/bin|
$fish_user_paths: set in universal scope, unexported, with 4 elements
$fish_user_paths[1]: |/Users/brianfogel/.npm-global/bin|
$fish_user_paths[2]: |/usr/local/sbin|
$fish_user_paths[3]: |/Applications/Postgres.app/Contents/Versions/latest/bin|
$fish_user_paths[4]: |/Users/brianfogel/.yarn/bin|
The Npm command not found error can appear when you install or upgrade npm. On Windows, the cause of this error could be that a PATH or system variable is not correctly set. The error can also occur if you do not have npm or Node. js installed, have an outdated version, or have permission issues.
nvm installs Node which installs npm. If you don't need/want to switch between Node versions then you don't probably don't need nvm.
nvm manages node.js and npm versions. It’s designed to be installed per-user and invoked per-shell. nvm works on any POSIX-compliant shell (sh, dash, ksh, zsh, bash), in particular on these platforms: unix, macOS, and windows WSL. nvm can be installed by curl or wget command:
NVM does not support fish shell. Fortunately, there is an easy way to fix that. We can install the bass plugin to use utilities written for Bash. Install bass using fisher (you can also use oh-my-fish).
After installation, you run following commands to setup specific node version: d:\>nvm install 4.7.2 d:\>nvm use 4.7.2 d:\>node --version and if you get following message ‘node’ is not recognized as an internal or external command, operable program or batch file.
New shells start with the default version of node. To set a default Node version in any new shell, use the alias ‘default’: If you want to use a specific version of NodeJS for your project, you can specify the NodeJS version inside of .nvmrc file inside of your project e.g. 12.13.1 and then activate it using nvm use command in your shell.
https://github.com/FabioAntunes/fish-nvm has been updated. Installing or updating the plugin fixes the problem.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With