In the latest version of dfx, the default frontend project template uses a workspace setup. It’s possible that you accidentally deleted the workspace but left the workspace-level scripts.
You can regenerate the necessary files with the commands dfx generate and tsc && vite build.
Yeah, I fixed that error, it was due to node.js not installed in my wsl , so it couldn’t geneate the frontend set up with vite +tsc . But , I installed node.js and created the app and it’s working. Thanks.
But, now since the app is working , I have a couple of doubts. Could you plz. clarify the same.
On running dfx deploy , it’s auto generate a declarations folder which have poll_backend and poll_frontend as sub -directories. What is actual purpose of these folders in my code. and Is it a good practice to do any changes in these directory at some point if needed ?
This is related to your networks.json file in your dfx configuration. You will need to specify a custom network for localhost:4943 to work in addition to 127.0.0.1:4943: Defining custom networks | Internet Computer
@Jessie,
I have located the netrwork.json file on my local system , using dfx cmd:
dfx info networks-json-path
It returns me the path as follows: /home/kundan/.config/dfx/networks.json
But, when I am running cat cmd to see the code:
cat /home/kundan/.config/dfx/networks.json
getting an error: cat: /home/kundan/.config/dfx/networks.json: No such file or directory
How, can I see that file and configure it’s code from my Vs code ?
dfx info networks-json-path shows where dfx is looking for the file, but doesn’t necessarily mean that it currently exists. If it doesn’t exist, you’ll need to create a new file in that location.
@Severin
On deploying my dapp on mainnet , I am getting the following error using cmd:
dfx deploy --network ic
Output :
Building canisters before generate for Motoko
WARN: .did file for canister 'poll_frontend' does not exist.
Generating type declarations for canister poll_frontend:
Error: Failed while trying to generate type declarations for 'poll_frontend'.
Caused by: Failed while trying to generate type declarations for 'poll_frontend'.
Candid file: /mnt/k/developer_journey/poll/.dfx/local/canisters/poll_frontend/assetstorage.did doesn't exist.
npm ERR! Lifecycle script `build` failed with error:
npm ERR! Error: command failed
npm ERR! in workspace: poll_frontend@0.0.0
npm ERR! at location: /mnt/k/developer_journey/poll/src/poll_frontend
@Jessie
On deploying my dapp on mainnet , I am getting the following error using cmd:
dfx deploy --network ic
Output :
Building canisters before generate for Motoko
WARN: .did file for canister 'poll_frontend' does not exist.
Generating type declarations for canister poll_frontend:
Error: Failed while trying to generate type declarations for 'poll_frontend'.
Caused by: Failed while trying to generate type declarations for 'poll_frontend'.
Candid file: /mnt/k/developer_journey/poll/.dfx/local/canisters/poll_frontend/assetstorage.did doesn't exist.
npm ERR! Lifecycle script `build` failed with error:
npm ERR! Error: command failed
npm ERR! in workspace: poll_frontend@0.0.0
npm ERR! at location: /mnt/k/developer_journey/poll/src/poll_frontend
Great job Jessie and big mahalo for all your work here! I finished the Motoko Bootcamp and this Journey is cool because it really starts at square 1 and helps one setup a local dev environment. Love it!
I’m on 1.3 and backend works great. It’s the frontend that’s a problem. It seems that the more recent version of node.js/dfx creates a different file structure on a dfx new and a vanilla JS when I compare my tree to yours in the video.
and if you strictly follow the tut, it definitely breaks. I can mess with it and get the index.html to render but the buttons don’t work.
It’s got to be such a pain to keep updating based on new versions. IMO cleaner and easier to stick to backend only and use Candid to test - save the agony of Node.js etc.
Anyway, if there’s an update LMK otherwise I’ll just keep going and essentially ignore the frontend stuff if it keeps breaking like this (which is fine by me - it’s motoko and ICP I care about anyway - never been much of a frontend guy as it is).
Hi @peterkayhi ! I appreciate the kind feedback and I’m glad you’re enjoying the series!
To get the frontend working, you can clone the Github repo for the 1.3 project and use that, since the file structure should still work as expected in that code.
looks like this repo needs webpack which was not originally called for (in 0.3). Pardon me for flying blind here - so I installed webpack using brew. Details below - I’m at a loss on what’s next - is the brew-based install a bad idea? (I followed your use of brew to install node.js) what do you recommend?
Now when deploying I get tons of errors but I think the key one is this: