fnm icon indicating copy to clipboard operation
fnm copied to clipboard

fnm should check the architecture of a Node.js installation to determine if it's already installed

Open jonahsnider opened this issue 2 years ago • 1 comments

Here is the output on my arm64 MacBook which had a pre-existing x86_64 Node.js installation from fnm:

$ node -p 'os.arch()'
x64
$ fnm install 16
Installing Node v16.15.0 (arm64)
warning: Version already installed at "/Users/jonah/.fnm/node-versions/v16.15.0"
$ node -p 'os.arch()'
x64

This is not what I'd expect fnm to do here. Instead, it should install the arm64 version and replace the old x86_64 version:

$ node -p 'os.arch()'
x64
$ fnm install 16
Installing Node v16.15.0 (arm64)
$ node -p 'os.arch()'
arm64

You can use this Nushell script to reinstall all Node versions currently installed with fnm to get the updated CPU architecture versions:

fnm ls | lines | each { |it| str replace -a '(^\* )|( default$)' '' } | each { |it| str trim } | where ($it | str starts-with 'v') | each { |it| str trim -c 'v' } | each { |it| fnm uninstall $it; fnm install $it }

jonahsnider avatar May 02 '22 01:05 jonahsnider

maybe you can use export FNM_ARCH="x64" and fnm install 16;

if working, you can writing in profile;

JohyC avatar May 05 '22 02:05 JohyC