Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"no version found" error on Mac with M1 chip #641

Closed
shadowspawn opened this issue Nov 27, 2020 · 18 comments
Closed

"no version found" error on Mac with M1 chip #641

shadowspawn opened this issue Nov 27, 2020 · 18 comments

Comments

@shadowspawn
Copy link
Collaborator

shadowspawn commented Nov 27, 2020

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:

@shadowspawn shadowspawn pinned this issue Nov 27, 2020
@soffes

This comment has been minimized.

@shadowspawn

This comment has been minimized.

@shadowspawn

This comment has been minimized.

@shadowspawn
Copy link
Collaborator Author

shadowspawn commented Dec 12, 2020

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.)

@mununki

This comment has been minimized.

@shadowspawn

This comment has been minimized.

@mununki

This comment has been minimized.

@parndt

This comment has been minimized.

@shadowspawn

This comment has been minimized.

@parndt

This comment has been minimized.

@shadowspawn
Copy link
Collaborator Author

Some discussion on nodejs/build#2474 in last day is that nodejs are thinking of shipping a fat binary from node 16.

@parndt
Copy link

parndt commented Jan 26, 2021

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:
image

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.

@dac09
Copy link

dac09 commented Apr 12, 2021

Hey! My solution was slightly different to the above,

  1. Move the appropriate version from /opt/homebrew/Cellar/node to ~/n/n/versions/node/
    e.g.
    mv /opt/homebrew/Cellar/node/15.4.0 ~/n/n/versions/node/

  2. Create a softlink in brew's cellar so your other scripts can still continue using the system one

cd /opt/homebrew/Cellar/node
ln -s ~/n/n/versions/node/15.14.0

@shadowspawn
Copy link
Collaborator Author

Node.js 16 will have a native Apple silicon build (arm64).

There will be a new version of n to default to arm64 native for Node.js v16 and higher.

If Node.js 16 comes out before n is updated, then for n v6.8.0 through v7.1.0 you can specify the architecture explicitly to override it defaulting to x64:

n --arch arm64 16

n does not keep track of which architecture is downloaded, so if you installed x64 first then remove it and download again:

n rm 16
n --arch arm64 16

@parndt
Copy link

parndt commented Apr 17, 2021

Thanks @shadowspawn that's great news 🏆

@shadowspawn
Copy link
Collaborator Author

shadowspawn commented Apr 19, 2021

Released n v7.2.1 in preparation for Node.js 16 release.

  • install native arm64 Node.js on Macs with Apple silicon for Node.js 16 and higher

@parndt
Copy link

parndt commented Apr 20, 2021

➜  ~ n --version
7.2.1
➜  ~ n 16
  installing : node-v16.0.0
       mkdir : /Users/parndt/n/n/versions/node/16.0.0
       fetch : https://nodejs.org/dist/v16.0.0/node-v16.0.0-darwin-arm64.tar.xz
   installed : v16.0.0 (with npm 7.10.0)

🎉 ✅ problem solved @shadowspawn

@shadowspawn
Copy link
Collaborator Author

Thanks for confirming @parndt 😄

I don't have an Apple Silicon Mac and the index.tab did not get updated with arm64 until this morning and Node.js 16 wasn't out, so while I was fairly confident from manual tests, good to hear it works with the actual release!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants