rustwebassemblyrust-wasmwasm-pack

Npm cannot find an executable while running the create-wasm-app JavaScript project template


I have been following a Rust + WebAssembly Tutorial and on the 2nd part of the 2nd chapter, after looking into the files and telling you how to build them, the tutorial asks you to run this command: npm init wasm-app www. Running this, even after I have gone back and redone all the steps twice, resulted in this error: Npm Error Could not find executable to run The build completed with no errors or irregularities.

Feel welcome to ask any questions you may have about the problem

0 verbose cli C:\Users\Name\AppData\Local\fnm_multishells\28000_1721347052931\node.exe C:\Users\Name\AppData\Local\fnm_multishells\28000_1721347052931\node_modules\npm\bin\npm-cli.js
1 info using npm@10.8.1
2 info using node@v22.4.1
3 silly config load:file:C:\Users\Name\AppData\Roaming\fnm\node-versions\v22.4.1\installation\node_modules\npm\npmrc
4 silly config load:file:C:\Users\Name\RustroverProjects\wasm-game-of-life\.npmrc
5 silly config load:file:C:\Users\Name\.npmrc
6 silly config load:file:C:\Users\Name\AppData\Local\fnm_multishells\28000_1721347052931\etc\npmrc
7 verbose title npm init wasm-app www
8 verbose argv "init" "wasm-app" "www"
9 verbose logfile logs-max:10 dir:C:\Users\Name\AppData\Local\npm-cache\_logs\2024-07-18T23_58_08_742Z-
10 verbose logfile C:\Users\Name\AppData\Local\npm-cache\_logs\2024-07-18T23_58_08_742Z-debug-0.log
11 silly logfile start cleaning logs, removing 1 files
12 silly logfile done cleaning log files
13 silly packumentCache heap:4345298944 maxSize:1086324736 maxEntrySize:543162368
14 http fetch GET 200 https://registry.npmjs.org/create-wasm-app 361ms (cache revalidated)
15 verbose stack Error: could not determine executable to run
15 verbose stack     at getBinFromManifest (C:\Users\Name\AppData\Roaming\fnm\node-versions\v22.4.1\installation\node_modules\npm\node_modules\libnpmexec\lib\get-bin-from-manifest.js:17:23)
15 verbose stack     at exec (C:\Users\Name\AppData\Roaming\fnm\node-versions\v22.4.1\installation\node_modules\npm\node_modules\libnpmexec\lib\index.js:198:15)
15 verbose stack     at async Init.execCreate (C:\Users\Name\AppData\Roaming\fnm\node-versions\v22.4.1\installation\node_modules\npm\lib\commands\init.js:136:5)
15 verbose stack     at async Init.exec (C:\Users\Name\AppData\Roaming\fnm\node-versions\v22.4.1\installation\node_modules\npm\lib\commands\init.js:44:14)
15 verbose stack     at async Npm.exec (C:\Users\Name\AppData\Roaming\fnm\node-versions\v22.4.1\installation\node_modules\npm\lib\npm.js:207:9)
15 verbose stack     at async module.exports (C:\Users\Name\AppData\Roaming\fnm\node-versions\v22.4.1\installation\node_modules\npm\lib\cli\entry.js:74:5)
16 verbose pkgid create-wasm-app@0.1.0
17 error could not determine executable to run
18 verbose cwd C:\Users\Name\RustroverProjects\wasm-game-of-life
19 verbose os Windows_NT 10.0.22631
20 verbose node v22.4.1
21 verbose npm  v10.8.1
22 verbose exit 1
23 verbose code 1
24 error A complete log of this run can be found in: C:\Users\Name\AppData\Local\npm-cache\_logs\2024-07-18T23_58_08_742Z-debug-0.log


Solution

  • I faced the same problem with npm version 10.8.2, and was able to get this to work by downgrading my npm to version 10.7.0.

    The thing to remember about the create-wasm-app package (which this init command is based on) is that — as of this writing — it has not been updated in 6 years.

    $ which npm
    /c/Program Files/nodejs/npm
    
    $ npm --version
    10.7.0
    
    $ npm init wasm-app www2
    
    > npx
    > create-wasm-app www2
    
    🦀 Rust +  Wasm = ❤