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

Can't install Bun via npm/npx on Mac with an M1 processor #5806

Closed
mathiasrw opened this issue Sep 20, 2023 · 19 comments
Closed

Can't install Bun via npm/npx on Mac with an M1 processor #5806

mathiasrw opened this issue Sep 20, 2023 · 19 comments
Labels
bug Something isn't working bun install Something that relates to the npm-compatible client

Comments

@mathiasrw
Copy link
Contributor

What is the problem this feature would solve?

Node and npm/npx are on lots of (most) systems today.

To be able to provide easy one-liners for running scripts across computers it would be great if we can have npx execute bun like this

npx bun script.js

I know - its better to to install globally, but this will make the transition easier.

What is the feature you are proposing to solve the problem?

Make sure that npx bun script.js works. At the moment (with v1.0.2) it spits out

Failed to find package "@oven/bun-darwin-aarch64". You may have used the "--no-optional" flag when running "npm install".
Error: Failed to install package "bun"
    at /Users/mwulff/git/alasql/node_modules/bun/bin/bun:312:11
    at Generator.throw (<anonymous>)
    at rejected (/Users/mwulff/git/alasql/node_modules/bun/bin/bun:36:27)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

What alternatives have you considered?

We can keep asking people to install yet another something, but lots or people are not allowed to install extra things (but have access to node behind the company firewall)

@mathiasrw mathiasrw added the enhancement New feature or request label Sep 20, 2023
@irfanshaik11
Copy link

I'm getting the same on a mac m1

@hengshanMWC
Copy link

hengshanMWC commented Sep 26, 2023

mac m1 Same question
image

System:
OS: macOS 11.4
CPU: (8) arm64 Apple M1
Memory: 100.84 MB / 16.00 GB
Shell: 5.8 - /bin/zsh
Binaries:
Node: 18.12.1 - ~/.nvm/versions/node/v18.12.1/bin/node
npm: 9.7.1 - ~/.nvm/versions/node/v18.12.1/bin/npm
pnpm: 7.21.0 - ~/.nvm/versions/node/v18.12.1/bin/pnpm
Browsers:
Chrome: 116.0.5845.187
Safari: 14.1.1

@mathiasrw mathiasrw changed the title Let npx execute bun as package Can't install Bun via npm/npx on Mac with an M1 processor Sep 27, 2023
@robobun robobun changed the title Can't install Bun via npm/npx on Mac with an M1 processor Can't install Bun via npm/npx on Mac with an M1 processor Sep 27, 2023
@mathiasrw
Copy link
Contributor Author

Should probably have a "bug" tag instead of enhancement.

@Electroid Electroid added bug Something isn't working bun install Something that relates to the npm-compatible client and removed enhancement New feature or request labels Sep 27, 2023
@maxenz
Copy link

maxenz commented Oct 2, 2023

same happening to me, any solution?

@MARCA-Charlie
Copy link

MARCA-Charlie commented Oct 5, 2023

Same error on M2 Pro. Problem appears to be with "@oven/bun-darwin-aarch64" package.

npm i @oven/bun-darwin-aarch64 yields the following error.

npm ERR! code EBADPLATFORM
npm ERR! notsup Unsupported platform for @oven/bun-darwin-aarch64@1.0.4: wanted {"os":"darwin","arch":"arm64"} (current: {"os":"darwin","arch":"x64"})
npm ERR! notsup Valid OS:    darwin
npm ERR! notsup Valid Arch:  arm64
npm ERR! notsup Actual OS:   darwin
npm ERR! notsup Actual Arch: x64

The complete log:

0 verbose cli /Users/charlietimlin/.nvm/versions/node/v14.18.3/bin/node /Users/charlietimlin/.nvm/versions/node/v14.18.3/bin/npm
1 info using npm@8.13.1
2 info using node@v14.18.3
3 timing npm:load:whichnode Completed in 0ms
4 timing config:load:defaults Completed in 3ms
5 timing config:load:file:/Users/charlietimlin/.nvm/versions/node/v14.18.3/lib/node_modules/npm/npmrc Completed in 4ms
6 timing config:load:builtin Completed in 4ms
7 timing config:load:cli Completed in 1ms
8 timing config:load:env Completed in 1ms
9 timing config:load:file:/Users/charlietimlin/Documents/localDevelopment/webflow/.npmrc Completed in 0ms
10 timing config:load:project Completed in 5ms
11 timing config:load:file:/Users/charlietimlin/.npmrc Completed in 1ms
12 timing config:load:user Completed in 1ms
13 timing config:load:file:/Users/charlietimlin/.nvm/versions/node/v14.18.3/etc/npmrc Completed in 0ms
14 timing config:load:global Completed in 1ms
15 timing config:load:validate Completed in 0ms
16 timing config:load:credentials Completed in 1ms
17 timing config:load:setEnvs Completed in 1ms
18 timing config:load Completed in 18ms
19 timing npm:load:configload Completed in 18ms
20 timing npm:load:mkdirpcache Completed in 1ms
21 timing npm:load:mkdirplogs Completed in 0ms
22 verbose title npm i @oven/bun-darwin-aarch64
23 verbose argv "i" "@oven/bun-darwin-aarch64"
24 timing npm:load:setTitle Completed in 6ms
25 timing config:load:flatten Completed in 4ms
26 timing npm:load:display Completed in 10ms
27 verbose logfile logs-max:10 dir:/Users/charlietimlin/.npm/_logs
28 verbose logfile /Users/charlietimlin/.npm/_logs/2023-10-05T21_29_58_461Z-debug-0.log
29 timing npm:load:logFile Completed in 3ms
30 timing npm:load:timers Completed in 1ms
31 timing npm:load:configScope Completed in 0ms
32 timing npm:load Completed in 39ms
33 timing arborist:ctor Completed in 1ms
34 silly logfile start cleaning logs, removing 1 files
35 silly logfile done cleaning log files
36 timing arborist:ctor Completed in 0ms
37 timing idealTree:init Completed in 27ms
38 timing idealTree:userRequests Completed in 0ms
39 silly idealTree buildDeps
40 silly fetch manifest @oven/bun-darwin-aarch64@*
41 http fetch GET 200 https://registry.npmjs.org/@oven%2fbun-darwin-aarch64 12ms (cache hit)
42 silly placeDep ROOT @oven/bun-darwin-aarch64@1.0.4 OK for: @marca/webflow-tools@1.0.0 want: *
43 timing idealTree:#root Completed in 19ms
44 timing idealTree:node_modules/@oven/bun-darwin-aarch64 Completed in 0ms
45 silly fetch manifest @oven/bun-darwin-aarch64@1.0.3
46 silly fetch manifest @oven/bun-linux-aarch64@1.0.3
47 http fetch GET 200 https://registry.npmjs.org/@oven%2fbun-linux-aarch64 7ms (cache hit)
48 silly fetch manifest @oven/bun-linux-x64@1.0.3
49 http fetch GET 200 https://registry.npmjs.org/@oven%2fbun-linux-x64 4ms (cache hit)
50 silly fetch manifest @oven/bun-linux-x64-baseline@1.0.3
51 http fetch GET 200 https://registry.npmjs.org/@oven%2fbun-linux-x64-baseline 4ms (cache hit)
52 silly placeDep node_modules/bun @oven/bun-darwin-aarch64@1.0.3 OK for: bun@1.0.3 want: 1.0.3
53 silly placeDep ROOT @oven/bun-linux-aarch64@1.0.3 OK for: bun@1.0.3 want: 1.0.3
54 silly placeDep ROOT @oven/bun-linux-x64@1.0.3 OK for: bun@1.0.3 want: 1.0.3
55 silly placeDep ROOT @oven/bun-linux-x64-baseline@1.0.3 OK for: bun@1.0.3 want: 1.0.3
56 timing idealTree:node_modules/bun Completed in 28ms
57 timing idealTree:node_modules/@oven/bun-linux-aarch64 Completed in 0ms
58 timing idealTree:node_modules/@oven/bun-linux-x64 Completed in 0ms
59 timing idealTree:node_modules/@oven/bun-linux-x64-baseline Completed in 0ms
60 timing idealTree:node_modules/bun/node_modules/@oven/bun-darwin-aarch64 Completed in 0ms
61 timing idealTree:buildDeps Completed in 48ms
62 timing idealTree:fixDepFlags Completed in 1ms
63 timing idealTree Completed in 78ms
64 timing command:i Completed in 83ms
65 verbose stack Error: Unsupported platform
65 verbose stack     at checkPlatform (/Users/charlietimlin/.nvm/versions/node/v14.18.3/lib/node_modules/npm/node_modules/npm-install-checks/lib/index.js:34:25)
65 verbose stack     at Arborist.[checkPlatform] (/Users/charlietimlin/.nvm/versions/node/v14.18.3/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:240:5)
65 verbose stack     at Arborist.[checkEngineAndPlatform] (/Users/charlietimlin/.nvm/versions/node/v14.18.3/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:234:29)
65 verbose stack     at Arborist.buildIdealTree (/Users/charlietimlin/.nvm/versions/node/v14.18.3/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:221:42)
65 verbose stack     at async Promise.all (index 1)
65 verbose stack     at async Arborist.reify (/Users/charlietimlin/.nvm/versions/node/v14.18.3/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/reify.js:153:5)
65 verbose stack     at async Install.exec (/Users/charlietimlin/.nvm/versions/node/v14.18.3/lib/node_modules/npm/lib/commands/install.js:145:5)
65 verbose stack     at async module.exports (/Users/charlietimlin/.nvm/versions/node/v14.18.3/lib/node_modules/npm/lib/cli.js:78:5)
66 verbose pkgid @oven/bun-darwin-aarch64@1.0.4
67 verbose cwd /Users/charlietimlin/Documents/localDevelopment/webflow
68 verbose Darwin 22.4.0
69 verbose node v14.18.3
70 verbose npm  v8.13.1
71 error code EBADPLATFORM
72 error notsup Unsupported platform for @oven/bun-darwin-aarch64@1.0.4: wanted {"os":"darwin","arch":"arm64"} (current: {"os":"darwin","arch":"x64"})
73 error notsup Valid OS:    darwin
73 error notsup Valid Arch:  arm64
73 error notsup Actual OS:   darwin
73 error notsup Actual Arch: x64
74 verbose exit 1
75 timing npm Completed in 166ms
76 verbose unfinished npm timer reify 1696541398540
77 verbose unfinished npm timer reify:loadTrees 1696541398543
78 verbose code 1
79 error A complete log of this run can be found in:
79 error     /Users/charlietimlin/.npm/_logs/2023-10-05T21_29_58_461Z-debug-0.log

@shubham-bgi
Copy link

This and #6177 are duplicates.

Fixed it by making a fresh installation of nvm and node. I was using nvm which I migrated from an intel to M1. That's why it is causing issues.

@ImLunaHey
Copy link
Contributor

@shubham-bgi was the issue actually that or the fact you were trying this with a outdated node version?

@shubham-bgi
Copy link

I wasn't trying with an outdated version of Node but it is not the correct version for my Mac.
Since I migrated all my data from Intel i9 to M1 using Apple migration assistant it was using x64 or Intel-compatible node version.
if using nvm, you can check it with the command ls ~/.nvm/.cache/bin

Before the x64(intel) version of the node was installed.
before

After a fresh install of nvm and node, it's arm64 (apple silicon M1 and M2).
After

This fixed the issue.

Another quick fix is to use the force flag npm i -g -f bun. It overrides any OS checks.

@MARCA-Charlie
Copy link

I wasn't trying with an outdated version of Node but it is not the correct version for my Mac. Since I migrated all my data from Intel i9 to M1 using Apple migration assistant it was using x64 or Intel-compatible node version. if using nvm, you can check it with the command ls ~/.nvm/.cache/bin

Before the x64(intel) version of the node was installed. before

After a fresh install of nvm and node, it's arm64 (apple silicon M1 and M2). After

This fixed the issue.

Another quick fix is to use the force flag npm i -g -f bun. It overrides any OS checks.

I see the same! Interesting. I'll reinstall node later and report back if it works for me. Thanks

@itsjavi
Copy link

itsjavi commented Oct 27, 2023

After removing node_modules and reinstalled packages it's solved, but the problem is back when I run pnpm install multiple times:

node_modules/.pnpm/bun@1.0.7/node_modules/bun: Running postinstall script, failed in 334ms
.../.pnpm/bun@1.0.7/node_modules/bun postinstall$ node install.js
│ Failed to find package "@oven/bun-darwin-aarch64". You may have used the "--no-optional" flag when running "npm install".
│ Error: Failed to install package "bun"

@AlexanderTunick
Copy link

AlexanderTunick commented Nov 29, 2023

This should be a fix for you:
I had this error today when trying to install bun. Turned out the root cause of the issue was the difference in architecture between my old Intel MacBook pro and my current M2 Pro Max. Since I used Apple data migration from the old Mac to the new one the packages that were installed on top of intel are kinda broken for Silicon. I had to remove all packet managers, node etc, and to make the fresh install of all it again.

After that everything worked out correctly.

@kyldvs
Copy link

kyldvs commented Dec 9, 2023

This fixes the issue for me while using pnpm in a turbo mono repo on M2 Pro Max:

rm -rf ./node_modules
pnpm i
pnpm -w add bun

@nektro
Copy link
Contributor

nektro commented Jan 23, 2024

does this still reproduce for you? how about npx bun@1.0.25 script.js ?

@mathiasrw
Copy link
Contributor Author

Seems to work now.

@kyldvs
Copy link

kyldvs commented Feb 5, 2024

This is still an issue in 1.0.25 with pnpm, should this be re-opened or want a new issue started?

image

@mathiasrw
Copy link
Contributor Author

New issue please.

@kyldvs
Copy link

kyldvs commented Feb 11, 2024

Same here, very disappointed, can't install bun on M1 Mac

pnpm i -f has always worked for me to work around the issue. It's always been a temporary blocker

@AstralBaby
Copy link

im getting Failed to find package "@oven/bun-darwin-aarch64" althought i was able to install it 🥱 very disappointing, was about to give bun a chance, but it looks like its to early, 4 hours wasted just to go back to node

@ouzhou
Copy link

ouzhou commented Apr 17, 2024

just change nodejs arch to arm64 by using nvm, default nodejs use x64

nvm install v20.12.2 --arch arm64
# temp use in current iterm
nvm use v20.12.2
# always set nodejs default version
nvm alias default  v20.12.2

then

npm i -g bun

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working bun install Something that relates to the npm-compatible client
Projects
None yet
Development

No branches or pull requests