Looking for ICP developers who are using Apple silicon to help me with this stubborn problem.
I have pulled this fullstack project from Github: GitHub - rvanasa/vite-react-motoko: Starter project for Vite + React + TypeScript + Motoko
and double checked that my OSX, nodjs, npm, and dfx are all running the latest versions. When I enter the command >npm run setup, I always get this crash:
Deploying all canisters.
All canisters have already been created.
Building canisters…
Building frontend…
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 ‘bd3sg-teaaa-aaaaa-qaaba-cai’ (frontend) with an embedded error: Failed to build frontend for network ‘local’.: The command ‘cd “/Users/none/VSCode/websites/icp” && BACKEND_CANISTER_ID=“bkyz2-fmaaa-aaaaa-qaaaq-cai” CANISTER_CANDID_PATH=“/Users/none/VSCode/websites/icp/.dfx/local/canisters/frontend/assetstorage.did” CANISTER_CANDID_PATH_BACKEND=“/Users/none/VSCode/websites/icp/.dfx/local/canisters/backend/backend.did” CANISTER_CANDID_PATH_backend=“/Users/none/VSCode/websites/icp/.dfx/local/canisters/backend/backend.did” CANISTER_ID=“bd3sg-teaaa-aaaaa-qaaba-cai” CANISTER_ID_BACKEND=“bkyz2-fmaaa-aaaaa-qaaaq-cai” CANISTER_ID_FRONTEND=“bd3sg-teaaa-aaaaa-qaaba-cai” CANISTER_ID_backend=“bkyz2-fmaaa-aaaaa-qaaaq-cai” CANISTER_ID_frontend=“bd3sg-teaaa-aaaaa-qaaba-cai” DFX_NETWORK=“local” DFX_VERSION=“0.15.3” FRONTEND_CANISTER_ID=“bd3sg-teaaa-aaaaa-qaaba-cai” “npm” “run” “build”’ failed with exit status ‘exit status: 1’.
Stdout:
vite-react-motoko@0.0.0 build
tsc && vite build
Stderr:
failed to load config from /Users/none/VSCode/websites/icp/vite.config.ts
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: Node.js — 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:
Keep in mind that this means multiple copies of esbuild will be present.
Another user posted about this previously (Esbuild on macOs M1 (apple chip)) but the solution he provided did not work for me. Reaching out to all apple arm devs for help!
Simple ICP cannisters run fine for me using the dfx deploy command, but any project which contains the esbuild node_module always throws this error and I have been trying to fix it all damn day.