krpeacock / access-control-tutorial

Code for Kyle's Motoko Bootcamp presentation on Motoko + Authentication
https://qizwk-hqaaa-aaaab-qaida-cai.icp0.io/
5 stars 1 forks source link

Error on deploying after cloning the repository #2

Open jacmos3 opened 1 year ago

jacmos3 commented 1 year ago

Hello! I would like to use this project to start learning how to integrate a motoko canister with a frontend app using the Internet Identity. But I am having problems on building this version of the project. I am using a MacBook Pro with M1 and dfx version 0.14.

Steps I've done:

During the deploy I am encountering the following error, do you how it is possible to fix it? many thanks!


Building frontend...
Error: Failed while trying to deploy canisters.
Caused by: Failed while trying to deploy canisters.
  Failed to build call 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 '"npm" "run" "build"' failed with exit status 'exit status: 1'.
Stdout:

> access-control-tutorial@1.0.0 build
> vite build src/frontend --config vite.config.js

Stderr:
failed to load config from /Users/jacopo/motoko_bootcamp/access-control-tutorial/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
want to do that.
krpeacock commented 1 year ago

What node version are you using? I'm also on an M1 Macbook. You can also check out https://github.com/krpeacock/auth-client-demo for a slightly different setup, but the same issue may be a problem there

jacmos3 commented 1 year ago

Hello, after a huge headache, I realized it is a node issue. I was using node v18. Then I downgraded to node 16 and now the code works.

Btw (I know it's not the correct thread here): just FIY I am also trying now the one you linked in your last message, but I am encountering an error after deployed the canister and started the frontend.. just after clicking the "login" button, it opens a blank page with this error on it: Replica Error (3): "IC0301: Canister a3shf-5eaaa-aaaaa-qaafa-cai not found"

Using macbook pro m1, node 16.20.0, npm 8.19.4, and dfx 0.14

thank you

krpeacock commented 1 year ago

Did you deploy the II canister as well?