tj / n

Node version management

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

zsh: command not found when running node

knobutan opened this issue · comments

Problem

I could install n, however cannot run node nor npm.

Short Version

n works fine, but node is not recognized.

% n --version        
v8.2.0

% node
zsh: command not found: node

Long Version

I am on a brand new Mac machine and installed using Homebrew. Gave adequate permission to the installation Path. n is correctly installed and I have set lts as its target.

% pwd
/usr/local/n/versions/node/16.15.1

% ls
CHANGELOG.md	LICENSE		README.md	bin		include		lib		share

//PATH does not have the bin of the node under n dir
% echo $PATH         
/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin

From the above result, I initially thought it is a matter of not having the right PATH, however I am not confident whether having node and npm is a prerequisite. Do I need to have node and npm installed already to use n?

Configuration Details

MacOS Monterey 12.2.1

% n --version
v8.2.0
% command -v node
% node -p process.platform
zsh: command not found: node

Thank you in advance for your help.

Resolved after re-installing it. Sharing the steps in case someone encounters this problem in the future.

% n prune
% n uninstall

// Went through the installation steps once again (Maybe I skipped some 
% sudo chown -R $(whoami) /usr/local/n 
% sudo mkdir -p /usr/local/bin /usr/local/lib /usr/local/include /usr/local/share
% sudo chown -R $(whoami) /usr/local/bin /usr/local/lib /usr/local/include /usr/local/share
% n install lts

Glad it is working for you now. Thanks for the update.