'npm init wasm-app www' failed

I am trying the following tutorial to investigate WebAssembly with Rust.
https://rustwasm.github.io/docs/book/game-of-life/hello-world.html

However, when I run "npm init wasm-app www" in section 4.2, I get the error in the attached image. Please let me know how to deal with it.

The error suggests it's git clone that fails. Do you already have a www dir in your project dir? If so, that would prevent git clone from completing successfully.

Thanks for the reply.
I created an empty directory and ran the same command but got the same error...

That's pretty odd.
I just double checked, the repo exists.

Could you post the contents of the log file mentioned by the error?

I'll paste the error log.

0 verbose cli C:\Program Files\nodejs\node.exe C:\Users\P-254\AppData\Roaming\npm\node_modules\npm\bin\npm-cli.js
1 info using npm@9.7.2
2 info using node@v18.13.0
3 timing npm:load:whichnode Completed in 3ms
4 timing config:load:defaults Completed in 4ms
5 timing config:load:file:C:\Users\P-254\AppData\Roaming\npm\node_modules\npm\npmrc Completed in 4ms
6 timing config:load:builtin Completed in 4ms
7 timing config:load:cli Completed in 1ms
8 timing config:load:env Completed in 1ms
9 timing config:load:file:C:\Users\P-254\Projects\WebAssembly\tmp\.npmrc Completed in 1ms
10 timing config:load:project Completed in 3ms
11 timing config:load:file:C:\Users\P-254\.npmrc Completed in 0ms
12 timing config:load:user Completed in 0ms
13 timing config:load:file:C:\Users\P-254\AppData\Roaming\npm\etc\npmrc Completed in 0ms
14 timing config:load:global Completed in 0ms
15 timing config:load:setEnvs Completed in 1ms
16 timing config:load Completed in 14ms
17 timing npm:load:configload Completed in 14ms
18 timing config:load:flatten Completed in 2ms
19 timing npm:load:mkdirpcache Completed in 0ms
20 timing npm:load:mkdirplogs Completed in 1ms
21 verbose title npm init wasm-app www
22 verbose argv "init" "wasm-app" "www"
23 timing npm:load:setTitle Completed in 1ms
24 timing npm:load:display Completed in 0ms
25 verbose logfile logs-max:10 dir:C:\Users\P-254\AppData\Local\npm-cache\_logs\2023-06-24T21_47_19_538Z-
26 verbose logfile C:\Users\P-254\AppData\Local\npm-cache\_logs\2023-06-24T21_47_19_538Z-debug-0.log
27 timing npm:load:logFile Completed in 17ms
28 timing npm:load:timers Completed in 0ms
29 timing npm:load:configScope Completed in 0ms
30 timing npm:load Completed in 58ms
31 timing arborist:ctor Completed in 0ms
32 silly logfile start cleaning logs, removing 2 files
33 silly logfile done cleaning log files
34 http fetch GET 200 https://registry.npmjs.org/create-wasm-app 123ms (cache revalidated)
35 timing arborist:ctor Completed in 0ms
36 timing arborist:ctor Completed in 0ms
37 timing command:init Completed in 261ms
38 verbose stack Error: command failed
38 verbose stack     at ChildProcess.<anonymous> (C:\Users\P-254\AppData\Roaming\npm\node_modules\npm\node_modules\@npmcli\promise-spawn\lib\index.js:53:27)
38 verbose stack     at ChildProcess.emit (node:events:513:28)
38 verbose stack     at maybeClose (node:internal/child_process:1091:16)
38 verbose stack     at ChildProcess._handle.onexit (node:internal/child_process:302:5)
39 verbose cwd C:\Users\P-254\Projects\WebAssembly\tmp
40 verbose Windows_NT 10.0.19045
41 verbose node v18.13.0
42 verbose npm  v9.7.2
43 error code 1
44 error path C:\Users\P-254\Projects\WebAssembly\tmp
45 error command failed
46 error command C:\WINDOWS\system32\cmd.exe /d /s /c create-wasm-app www
47 verbose exit 1
48 timing npm Completed in 621ms
49 verbose code 1
50 error A complete log of this run can be found in: C:\Users\P-254\AppData\Local\npm-cache\_logs\2023-06-24T21_47_19_538Z-debug-0.log

This is just a hunch, but you're running Node v18. Try downgrading to v16 and see if it works. I've had enough trouble with v18 that I still haven't bothered upgrading.

(If I recall correctly, v18 has problems with SSL/TLS connections, which could be preventing the download from GitHub happening).

I have tried downgrading Node.js to v16.20.1 and get the same error.

Do you mind posting the new error log?

I will paste new log.

0 verbose cli C:\Program Files\nodejs\node.exe C:\Users\P-254\AppData\Roaming\npm\node_modules\npm\bin\npm-cli.js
1 info using npm@9.7.2
2 info using node@v16.20.1
3 timing npm:load:whichnode Completed in 2ms
4 timing config:load:defaults Completed in 4ms
5 timing config:load:file:C:\Users\P-254\AppData\Roaming\npm\node_modules\npm\npmrc Completed in 3ms
6 timing config:load:builtin Completed in 3ms
7 timing config:load:cli Completed in 2ms
8 timing config:load:env Completed in 1ms
9 timing config:load:file:C:\Users\P-254\Projects\WebAssembly\wasm-game-of-life\.npmrc Completed in 0ms
10 timing config:load:project Completed in 2ms
11 timing config:load:file:C:\Users\P-254\.npmrc Completed in 0ms
12 timing config:load:user Completed in 0ms
13 timing config:load:file:C:\Users\P-254\AppData\Roaming\npm\etc\npmrc Completed in 0ms
14 timing config:load:global Completed in 0ms
15 timing config:load:setEnvs Completed in 1ms
16 timing config:load Completed in 13ms
17 timing npm:load:configload Completed in 13ms
18 timing config:load:flatten Completed in 2ms
19 timing npm:load:mkdirpcache Completed in 0ms
20 timing npm:load:mkdirplogs Completed in 1ms
21 verbose title npm init wasm-app www
22 verbose argv "init" "wasm-app" "www"
23 timing npm:load:setTitle Completed in 0ms
24 timing npm:load:display Completed in 1ms
25 verbose logfile logs-max:10 dir:C:\Users\P-254\AppData\Local\npm-cache\_logs\2023-06-25T01_36_03_373Z-
26 verbose logfile C:\Users\P-254\AppData\Local\npm-cache\_logs\2023-06-25T01_36_03_373Z-debug-0.log
27 timing npm:load:logFile Completed in 18ms
28 timing npm:load:timers Completed in 0ms
29 timing npm:load:configScope Completed in 0ms
30 timing npm:load Completed in 57ms
31 timing arborist:ctor Completed in 1ms
32 silly logfile start cleaning logs, removing 2 files
33 silly logfile done cleaning log files
34 http fetch GET 200 https://registry.npmjs.org/create-wasm-app 697ms (cache revalidated)
35 timing arborist:ctor Completed in 0ms
36 timing arborist:ctor Completed in 0ms
37 timing command:init Completed in 855ms
38 verbose stack Error: command failed
38 verbose stack     at ChildProcess.<anonymous> (C:\Users\P-254\AppData\Roaming\npm\node_modules\npm\node_modules\@npmcli\promise-spawn\lib\index.js:53:27)
38 verbose stack     at ChildProcess.emit (node:events:513:28)
38 verbose stack     at maybeClose (node:internal/child_process:1100:16)
38 verbose stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:304:5)
39 verbose cwd C:\Users\P-254\Projects\WebAssembly\wasm-game-of-life
40 verbose Windows_NT 10.0.19045
41 verbose node v16.20.1
42 verbose npm  v9.7.2
43 error code 1
44 error path C:\Users\P-254\Projects\WebAssembly\wasm-game-of-life
45 error command failed
46 error command C:\WINDOWS\system32\cmd.exe /d /s /c create-wasm-app www
47 verbose exit 1
48 timing npm Completed in 1208ms
49 verbose code 1
50 error A complete log of this run can be found in: C:\Users\P-254\AppData\Local\npm-cache\_logs\2023-06-25T01_36_03_373Z-debug-0.log

After looking at this similar problem

I'm wondering if it's caused by Windows Firewall and/or an antivirus program? Can you try disabling these and trying again? It does look like the download is failing for some reason.

I disabled the Firewall and anti-virus software and tried again, but the error still occurs.

0 verbose cli C:\Program Files\nodejs\node.exe C:\Users\P-254\AppData\Roaming\npm\node_modules\npm\bin\npm-cli.js
1 info using npm@9.7.2
2 info using node@v16.20.1
3 timing npm:load:whichnode Completed in 2ms
4 timing config:load:defaults Completed in 4ms
5 timing config:load:file:C:\Users\P-254\AppData\Roaming\npm\node_modules\npm\npmrc Completed in 4ms
6 timing config:load:builtin Completed in 4ms
7 timing config:load:cli Completed in 1ms
8 timing config:load:env Completed in 1ms
9 timing config:load:file:C:\Users\P-254\Projects\WebAssembly\wasm-game-of-life\.npmrc Completed in 1ms
10 timing config:load:project Completed in 3ms
11 timing config:load:file:C:\Users\P-254\.npmrc Completed in 0ms
12 timing config:load:user Completed in 0ms
13 timing config:load:file:C:\Users\P-254\AppData\Roaming\npm\etc\npmrc Completed in 0ms
14 timing config:load:global Completed in 0ms
15 timing config:load:setEnvs Completed in 1ms
16 timing config:load Completed in 14ms
17 timing npm:load:configload Completed in 14ms
18 timing config:load:flatten Completed in 2ms
19 timing npm:load:mkdirpcache Completed in 1ms
20 timing npm:load:mkdirplogs Completed in 0ms
21 verbose title npm init wasm-app www
22 verbose argv "init" "wasm-app" "www"
23 timing npm:load:setTitle Completed in 1ms
24 timing npm:load:display Completed in 1ms
25 verbose logfile logs-max:10 dir:C:\Users\P-254\AppData\Local\npm-cache\_logs\2023-06-25T02_30_32_697Z-
26 verbose logfile C:\Users\P-254\AppData\Local\npm-cache\_logs\2023-06-25T02_30_32_697Z-debug-0.log
27 timing npm:load:logFile Completed in 18ms
28 timing npm:load:timers Completed in 0ms
29 timing npm:load:configScope Completed in 0ms
30 timing npm:load Completed in 60ms
31 timing arborist:ctor Completed in 1ms
32 silly logfile start cleaning logs, removing 2 files
33 silly logfile done cleaning log files
34 http fetch GET 200 https://registry.npmjs.org/create-wasm-app 665ms (cache revalidated)
35 timing arborist:ctor Completed in 1ms
36 timing arborist:ctor Completed in 0ms
37 timing command:init Completed in 810ms
38 verbose stack Error: command failed
38 verbose stack     at ChildProcess.<anonymous> (C:\Users\P-254\AppData\Roaming\npm\node_modules\npm\node_modules\@npmcli\promise-spawn\lib\index.js:53:27)
38 verbose stack     at ChildProcess.emit (node:events:513:28)
38 verbose stack     at maybeClose (node:internal/child_process:1100:16)
38 verbose stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:304:5)
39 verbose cwd C:\Users\P-254\Projects\WebAssembly\wasm-game-of-life
40 verbose Windows_NT 10.0.19045
41 verbose node v16.20.1
42 verbose npm  v9.7.2
43 error code 1
44 error path C:\Users\P-254\Projects\WebAssembly\wasm-game-of-life
45 error command failed
46 error command C:\WINDOWS\system32\cmd.exe /d /s /c create-wasm-app www
47 verbose exit 1
48 timing npm Completed in 1159ms
49 verbose code 1
50 error A complete log of this run can be found in: C:\Users\P-254\AppData\Local\npm-cache\_logs\2023-06-25T02_30_32_697Z-debug-0.log

From the command line, can you successfully run this command: git clone https://github.com/rustwasm/create-wasm-app.git

Also, perhaps try running the terminal as Administrator and see if that works?

I ran the command, but it did not recognize git as a command. I usually use git in SourceTree, so perhaps it is not in the path. I am not sure, but there is no mention of installing GIT in the tutorial setup, do I need to do that?

Yeah, the NPM script calls git, so you should install it and make sure it is accessible from the PATH variable. If you have SourceTree, it should be installed already, but may not be on the PATH.

I think you're right that the tutorial doesn't mention installing git, but unfortunately git is so widely used now that documentation often assumes you have it already.

2 Likes

I ran the command through the path to git.exe (setting the environment variable) and npm init wasm-app www now succeeds. Thank you very much for your kind reply.

Great! :smiley:

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.