create-ic-app icon indicating copy to clipboard operation
create-ic-app copied to clipboard

react sample can't find counter.did.js - (workaround provided)

Open augchan42 opened this issue 1 year ago • 2 comments

The counter.did.js file can't be found under ../.dfx/local/canisters/counter. I tried react+javascript and react+typescript. Seems the build needs to include dfx generate.

I had to: 1) generate the candid interfaces manually using dfx generate. 2) Update the App.jsx file with the proper import:

import * as counter from "../src/declarations/counter"

Stderr: Could not resolve './counter.did.js' from .dfx/local/canisters/counter/index.js error during build: Error: Could not resolve './counter.did.js' from .dfx/local/canisters/counter/index.js at error (/home/hosermage/projects/dfinity/create-ic-app/ledger_sample_react/node_modules/rollup/dist/shared/rollup.js:198:30) at ModuleLoader.handleResolveId (/home/hosermage/projects/dfinity/create-ic-app/ledger_sample_react/node_modules/rollup/dist/shared/rollup.js:22464:24) at /home/hosermage/projects/dfinity/create-ic-app/ledger_sample_react/node_modules/rollup/dist/shared/rollup.js:22427:26

augchan42 avatar Jan 10 '24 05:01 augchan42

just noting -- I ran into the same issue (same fix).

In my case, also needed to run

yarn add @dfinity/candid

amva13 avatar Feb 11 '24 21:02 amva13

Did the counter actually work? I just did this, got the web page and everything to load, but it's not hitting the backend canister with the counter logic.

theofandrich avatar Feb 14 '24 03:02 theofandrich