Using n current or n 8 etc on a Mac with the M1 chip and an older version of n will currently display an error that "no version found", because there are not yet native versions of node available for the new architecture.
You can download and run node built for the Intel x64 architecture. The installed node will run using Rosetta 2. e.g.
n --arch x64 lts
Another approach is to launch Terminal itself using Rosetta, so that the terminal environment assumes x64.
The n behaviour on Apple M1 will be reviewed when nodejs decide their plans for support:
n latest on an M1 shows Error: no version found for 'latest'. I installed it with Homebrew. Never used n before so unsure if I'm doing something wrong. n shows the help and n latest shows that error. Didn't try anything else.
Someone on my team suggested I use nvm instead and that is working fine for me.
Your situation is what this issue is covering @soffes . For now, you can do installs by specifying the architecture.
I have been wondering about releasing an interim version of n which defaults to x64 for now, and fine tune it after nodejs start releasing native versions.
Readers, let me know if this would be useful with a ๐ or comment.
Released n v6.8.0 which defaults to x64 on a Mac with the M1 chip. This is included in n v7.0.0 too.
(The native architecture is arm64 if you need to specify it to try a new release before n catches up. n does not separate the downloads by architecture, so if you are changing architectures for a specific version then delete the old download before installing again with the desired architecture.)
@shadowspawn Recently, I got a M1 air, then I installed the latest version of n. But, it installed the x64 arch node v14 lts after the normal initial installation.
Can you help me to install the arm64 node version with n?
@mattdamon108 There are not yet any prebuilt arm64 binaries available for Mac:
@shadowspawn oh! thank you for clarification!
Looks like there are now, at least version 15.7.0 has a prebuilt arm64 for darwin - https://nodejs.org/dist/v15.7.0/node-v15.7.0-darwin-arm64.tar.xz - however trying to install this version gives x64:
โ n 15
installing : node-v15.7.0
mkdir : /Users/parndt/n/n/versions/node/15.7.0
fetch : https://nodejs.org/dist/v15.7.0/node-v15.7.0-darwin-x64.tar.xz
installed : v15.7.0 (with npm 7.4.3)
so I tried again with --arch:
โ n --arch arm64 15
Error: no version found for '15'
@parndt
That might have been released in error, I think the prebuilt arm64 has gone again!
That might have been released in error, I think the arm64 has gone again!
@shadowspawn wow, you're right! ๐ฑ it's gone.
Some discussion on https://github.com/nodejs/build/issues/2474 in last day is that nodejs are thinking of shipping a fat binary from node 16.
Thanks for the info! ๐
For now, I'll continue to use my workaround via Homebrew which I'll document here in case it helps anyone else:
brew install node # this gets the arm64 version compiled by Homebrew, currently 15.6.0
$ n 15.6.0
installing : node-v15.6.0
mkdir : /Users/parndt/n/n/versions/node/15.6.0
fetch : https://nodejs.org/dist/v15.6.0/node-v15.6.0-darwin-x64.tar.xz
installed : v15.6.0 (with npm 7.4.0)
$ rm -rf ~/n/n/versions/node/15.6.0
$ cp -r /opt/homebrew/Cellar/node/15.6.0 ~/n/n/versions/node/
$ brew uninstall node
$ n 15.6
installed : v15.6.0 (with npm 7.4.3)
When it runs, activity monitor happily shows the Architecture as "Apple" as expected:

If an older version is installed, e.g. Node 12, which has a different lib/node_modules/npm then problems arise, but if mostly using one version it seems OK.
Most helpful comment
Thanks for the info! ๐
For now, I'll continue to use my workaround via Homebrew which I'll document here in case it helps anyone else:
When it runs, activity monitor happily shows the Architecture as "Apple" as expected:

If an older version is installed, e.g. Node 12, which has a different
lib/node_modules/npmthen problems arise, but if mostly using one version it seems OK.