# Esbuild on macOs M1 (apple chip)

**URL:** <https://forum.dfinity.org/t/esbuild-on-macos-m1-apple-chip/21876>\
**Category:** Developers\
**Tags:** TypeScript, Frontend\
**Created:** [August 1, 2023, 3:51pm UTC](https://forum.dfinity.org/t/esbuild-on-macos-m1-apple-chip/21876 "2023-08-01T15:51:59Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![AliSci](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/alisci/32/33799_2.png) [@AliSci](https://forum.dfinity.org/u/AliSci)\
**Post date:** [August 1, 2023, 3:51pm UTC](https://forum.dfinity.org/t/esbuild-on-macos-m1-apple-chip/21876/1 "2023-08-01T15:51:59Z")

</div>

`dfx deploy frontend` cuses this issue

```auto
Error: Failed while trying to deploy canisters.
Caused by: Failed while trying to deploy canisters.
  Failed to build all canisters.
    Failed while trying to build all canisters.
      The post-build step failed for canister 'bw4dl-smaaa-aaaaa-qaacq-cai' (frontend) with an embedded error: Failed to build frontend for network 'local'.: The command '"npm" "run" "build"' failed with exit status 'exit status: 1'.
Stdout:

> dfn-react-ts@0.1.3 prebuild
> dfx generate

> dfn-react-ts@0.1.3 build
> vite build

Stderr:
Generating type declarations for canister user_canister:
  src/declarations/user_canister/user_canister.did.d.ts
  src/declarations/user_canister/user_canister.did.js
  src/user_canister/user_canister.did
Generating type declarations for canister frontend:
  src/declarations/frontend/frontend.did.d.ts
  src/declarations/frontend/frontend.did.js
  src/declarations/frontend/frontend.did
failed to load config from /Users/ahmed/Desktop/odoc/vite.config.js
error during build:
Error: 
You installed esbuild for another platform than the one you're currently using.
This won't work because esbuild is written with native code and needs to
install a platform-specific binary executable.

Specifically the "@esbuild/darwin-arm64" package is present but this platform
needs the "@esbuild/darwin-x64" package instead. People often get into this
situation by installing esbuild with npm running inside of Rosetta 2 and then
trying to use it with node running outside of Rosetta 2, or vice versa (Rosetta
2 is Apple's on-the-fly x86_64-to-arm64 translation service).

If you are installing with npm, you can try ensuring that both npm and node are
not running under Rosetta 2 and then reinstalling esbuild. This likely involves
changing how you installed npm and/or node. For example, installing node with
the universal installer here should work: https://nodejs.org/en/download/. Or
you could consider using yarn instead of npm which has built-in support for
installing a package on multiple platforms simultaneously.

If you are installing with yarn, you can try listing both "arm64" and "x64"
in your ".yarnrc.yml" file using the "supportedArchitectures" feature:
https://yarnpkg.com/configuration/yarnrc/#supportedArchitectures
Keep in mind that this means multiple copies of esbuild will be present.

Another alternative is to use the "esbuild-wasm" package instead, which works
the same way on all platforms. But it comes with a heavy performance cost and
can sometimes be 10x slower than the "esbuild" package, so you may also not

```

my system ifo

```auto
$ dfx --version
dfx 0.14.3

```

```auto
$ node -v
v18.17.0

```

```auto
macbook pro m1

```

---

<div class="post-metadata">

**Author:** ![infu](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/infu/32/11321_2.png) [@infu](https://forum.dfinity.org/u/infu)\
**Post date:** [August 1, 2023, 6:09pm UTC](https://forum.dfinity.org/t/esbuild-on-macos-m1-apple-chip/21876/2 "2023-08-01T18:09:06Z")

</div>

Not sure what you are building.  
Try `npm uninstall esbuild`  
and then `npm install esbuild` that should get the proper package.

---

<div class="post-metadata">

**Author:** ![sea-snake](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/sea-snake/32/7243_2.png) [@sea-snake](https://forum.dfinity.org/u/sea-snake)\
**Post date:** [August 1, 2023, 9:29pm UTC](https://forum.dfinity.org/t/esbuild-on-macos-m1-apple-chip/21876/3 "2023-08-01T21:29:35Z")

</div>

My best guess would be: if you run `npm install` from within your IDE/different terminal than `dfx deploy` there’s a risk that one command is run with Rosetta emulation and one without.

---

<div class="post-metadata">

**Author:** ![AliSci](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/alisci/32/33799_2.png) [@AliSci](https://forum.dfinity.org/u/AliSci)\
**Post date:** [August 9, 2023, 8:03am UTC](https://forum.dfinity.org/t/esbuild-on-macos-m1-apple-chip/21876/4 "2023-08-09T08:03:07Z")

</div>

Solved:  
by runing `sh -ci "$(curl -fsSL https://internetcomputer.org/install.sh)"`
