Could you please provide your specific steps?
I maybe reproduced the issue, but not sure if that’s the same one. Here’s my setup:
$ dfx --version
dfx 0.24.3
$ rustc --version
rustc 1.75.0 (82e1608df 2023-12-21)
The project without frontend works fine:
$ dfx new --type rust --no-frontend demo
$ cd demo
$ dfx start --clean --background
...
$ dfx deploy
$ dfx canister call demo_backend greet world
("Hello, world!")
The project with a default frontend fails to deploy a canister:
$ dfx new --type rust demo
...
$ cd demo
$ dfx start --clean --background
Running dfx start for version 0.24.3
Using the default configuration for the local shared network.
Initialized replica.
Initialized HTTP gateway.
Replica API running on 127.0.0.1:4943
Success! The dfx server is running in the background.
$ dfx deploy
Deploying all canisters.
Creating canisters...
Creating canister demo_backend...
demo_backend canister created with canister id: be2us-64aaa-aaaaa-qaabq-cai
Creating canister demo_frontend...
demo_frontend canister created with canister id: br5f7-7uaaa-aaaaa-qaaca-cai
Building canisters...
WARN: Cannot check for vulnerabilities in rust canisters because cargo-audit is not installed. Please run 'cargo install cargo-audit' so that vulnerabilities can be detected.
Executing: cargo build --target wasm32-unknown-unknown --release -p demo_backend --locked
Finished release [optimized] target(s) in 0.03s
Building frontend...
Error: Failed while trying to deploy canisters.
Caused by: Failed to build all canisters.
Caused by: Failed while trying to build all canisters.
Caused by: The post-build step failed for canister 'br5f7-7uaaa-aaaaa-qaaca-cai' (demo_frontend)
Caused by: Failed to build frontend for network 'local'.
Caused by: Error executing Command {
program: "npm",
args: [
"npm",
"run",
"build",
],
env: CommandEnv {
clear: false,
vars: {
"CANISTER_CANDID_PATH": Some(
"/home/maksym/tmp/demo/.dfx/local/canisters/demo_frontend/assetstorage.did",
),
"CANISTER_CANDID_PATH_DEMO_BACKEND": Some(
"/home/maksym/tmp/demo/src/demo_backend/demo_backend.did",
),
"CANISTER_ID": Some(
"br5f7-7uaaa-aaaaa-qaaca-cai",
),
"CANISTER_ID_DEMO_BACKEND": Some(
"be2us-64aaa-aaaaa-qaabq-cai",
),
"CANISTER_ID_DEMO_FRONTEND": Some(
"br5f7-7uaaa-aaaaa-qaaca-cai",
),
"DFX_NETWORK": Some(
"local",
),
"DFX_VERSION": Some(
"0.24.3",
),
},
},
cwd: Some(
"/home/maksym/tmp/demo",
),
stdout: Some(
MakePipe,
),
stderr: Some(
MakePipe,
),
create_pidfd: false,
}
Caused by: No such file or directory (os error 2)
UPD: the error message above suggests that npm
was not able to start properly, which is correct because I did not have it installed on my machine.
I looked at First smart contract | Internet Computer and installed nvm
and npm
as suggested there as a first step.
$ node -v
v23.5.0
$ nvm current
v23.5.0
$ npm -v
10.9.2
After that it all worked just fine. It’s always helpful to read error messages carefully. Hope that helps.