tj / n

Node version management

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

cannot install node version on m1 mac?

hcientist opened this issue · comments

Problem

Short Version

On an M1 mac, I have set N_PREFIX, but it seems not to work. I cannot install with n.

Long Version

I have installed n via homebrew, but I cannot install node for some reason.

~/d/music-cpr ❯❯❯ echo $N_PREFIX
~/.n
~/d/music-cpr ❯❯❯ n lts
  installing : node-v16.17.0
       mkdir : ~/.n/n/versions/node/16.17.0
       fetch : https://nodejs.org/dist/v16.17.0/node-v16.17.0-darwin-x64.tar.xz
     copying : node/16.17.0
find: ~/.n/n/versions/node/16.17.0/lib: No such file or directory
cp: ~/.n/n/versions/node/16.17.0/bin/node: No such file or directory
find: ~/.n/n/versions/node/16.17.0/include: No such file or directory
find: ~/.n/n/versions/node/16.17.0/share: No such file or directory
find: ~/.n/n/versions/node/16.17.0/share/man: No such file or directory
/opt/homebrew/bin/n: line 744: ~/.n/bin/node: No such file or directory
   installed : 
~/d/music-cpr ❯❯❯ ls -al ~/.n
total 0
drwxr-xr-x    2 tgm  staff    64 Sep  2 22:17 .
drwxr-xr-x@ 309 tgm  staff  9888 Sep 17 16:44 ..
~/d/music-cpr ❯❯❯ whoami
tgm

Configuration Details

~/d/music-cpr ❯❯❯ n --version
v9.0.0
~/d/music-cpr ❯❯❯ command -v node
/usr/local/bin/node
~/d/music-cpr ❯❯❯ node -p process.platform
darwin
~/d/music-cpr ❯❯❯ 

N_PREFIX needs to be the resolved path, and not a string with the tilde (~). The tilde in the environment variable does not get expanded when used in the code.

The shell did this for me when I tried reproducing, and this works with n.

% export N_PREFIX=~/.n
% echo $N_PREFIX
/Users/john/.n

But when I did this I saw the same errors as you:

% export N_PREFIX="~/.n"
% echo $N_PREFIX        
~/.n

I fixed this, then saw that my path hadn't been updated to include anything for n, I manually added $N_PREFIX/bin (after defining the prefix of course) and it got me rolling. thanks for your help!

# add n to path
export PATH="$PATH:$N_PREFIX/bin"