fnm icon indicating copy to clipboard operation
fnm copied to clipboard

npm/node is not found in the first shell opened

Open willparsons opened this issue 5 months ago • 3 comments

Whenever I first open my terminal npm and node cannot be found. I have to start a new shell.

System:

  • fish 4.0.2
  • fnm 1.38.1
  • WSL Ubuntu 24.04.2

Fish config:

# conf.d/fnm.fish
if status is-interactive
    fish_add_path -a "/home/will/.local/share/fnm"
    fnm env --shell fish | source
    fnm completions --shell fish | source
end

# config.fish
if status is-interactive
    # Commands to run in interactive sessions can go here
end

abbr --add ch chezmoi
abbr --add lg lazygit

fish_add_path -a /opt/nvim/bin

direnv hook fish | source
starship init fish | source


~
❯ npm
Command 'npm' not found, but can be installed with:
sudo apt install npm

~
❯ fnm env
set -gx PATH "/run/user/1000/fnm_multishells/1078_1752221320327/bin" $PATH;
set -gx FNM_MULTISHELL_PATH "/run/user/1000/fnm_multishells/1078_1752221320327";
set -gx FNM_VERSION_FILE_STRATEGY "local";
set -gx FNM_DIR "/home/will/.local/share/fnm";
set -gx FNM_LOGLEVEL "info";
set -gx FNM_NODE_DIST_MIRROR "https://nodejs.org/dist";
set -gx FNM_COREPACK_ENABLED "false";
set -gx FNM_RESOLVE_ENGINES "true";
set -gx FNM_ARCH "x64";

~
❯ echo $PATH
/run/user/1000/fnm_multishells/794_1752221314420/bin /home/will/.local/share/fnm

~
❯ ls /run/user/1000/fnm_multishells
1078_1752221320327@  883_1752221314920@

willparsons avatar Jul 11 '25 08:07 willparsons

Got same issue with fish shell.

> fnm env
set -gx PATH "/run/user/1000/fnm_multishells/6606_1754033039039/bin" $PATH;
set -gx FNM_MULTISHELL_PATH "/run/user/1000/fnm_multishells/6606_1754033039039";
set -gx FNM_VERSION_FILE_STRATEGY "local";
set -gx FNM_DIR "/home/vlad/.local/share/fnm";
set -gx FNM_LOGLEVEL "info";
set -gx FNM_NODE_DIST_MIRROR "https://nodejs.org/dist";
set -gx FNM_COREPACK_ENABLED "false";
set -gx FNM_RESOLVE_ENGINES "true";
set -gx FNM_ARCH "x64";
> fnm current
error: `fnm env` was not applied in this context.
Can't find fnm's environment variables
> fish --version
fish, version 3.7.0
> npm
Command 'npm' not found, but can be installed with:
sudo apt install npm

> node
Command 'node' not found, but can be installed with:
sudo apt install nodejs

vladaman avatar Aug 01 '25 07:08 vladaman

fnm env --use-on-cd --shell zsh
export PATH="/run/user/1000/fnm_multishells/126614_1758554541461/bin":$PATH
export FNM_MULTISHELL_PATH="/run/user/1000/fnm_multishells/126614_1758554541461"
export FNM_VERSION_FILE_STRATEGY="local"
export FNM_DIR="/home/wdhenin/.local/share/fnm"
export FNM_LOGLEVEL="info"
export FNM_NODE_DIST_MIRROR="https://nodejs.org/dist"
export FNM_COREPACK_ENABLED="false"
export FNM_RESOLVE_ENGINES="true"
export FNM_ARCH="x64"
autoload -U add-zsh-hook
_fnm_autoload_hook () {
    if [[ -f .node-version || -f .nvmrc || -f package.json ]]; then
    fnm use --silent-if-unchanged
fi

}

add-zsh-hook chpwd _fnm_autoload_hook \
    && _fnm_autoload_hook

rehash


node -v
zsh: command not found: node

same here very annoying...

ninehd avatar Sep 22 '25 15:09 ninehd

in fact I have done fnm default 22 and it works now

ninehd avatar Sep 22 '25 15:09 ninehd