create-wasm-app
create-wasm-app copied to clipboard
`npm init wasm-app www` fails
Describe the Bug
npm init wasm-app www fails.
Versions
>node --version
v20.16.0
>npm --version
10.8.2
Error
>npm init wasm-app www
npm error could not determine executable to run
npm error A complete log of this run can be found in: C:\Users\User\AppData\Local\npm-cache\_logs\2024-07-25T11_30_21_907Z-debug-0.log
// 2024-07-25T11_30_21_907Z-debug-0.log
0 verbose cli C:\Program Files\nodejs\node.exe C:\Users\User\AppData\Roaming\npm\node_modules\npm\bin\npm-cli.js
1 info using [email protected]
2 info using [email protected]
3 silly config load:file:C:\Users\User\AppData\Roaming\npm\node_modules\npm\npmrc
4 silly config load:file:C:\Users\User\Documents\_G\Source code\ATBA\wasm_example_2\.npmrc
5 silly config load:file:C:\Users\User\.npmrc
6 silly config load:file:C:\Users\User\AppData\Roaming\npm\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\User\AppData\Local\npm-cache\_logs\2024-07-25T11_15_43_784Z-
10 verbose logfile C:\Users\User\AppData\Local\npm-cache\_logs\2024-07-25T11_15_43_784Z-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 verbose shrinkwrap failed to load node_modules/.package-lock.json missing from node_modules: ../../../../../../../../usr/local/lib/node_modules/create-wasm-app
15 http fetch GET 200 https://registry.npmjs.org/create-wasm-app 311ms (cache revalidated)
16 verbose stack Error: could not determine executable to run
16 verbose stack at getBinFromManifest (C:\Users\User\AppData\Roaming\npm\node_modules\npm\node_modules\libnpmexec\lib\get-bin-from-manifest.js:17:23)
16 verbose stack at exec (C:\Users\User\AppData\Roaming\npm\node_modules\npm\node_modules\libnpmexec\lib\index.js:202:15)
16 verbose stack at async Init.execCreate (C:\Users\User\AppData\Roaming\npm\node_modules\npm\lib\commands\init.js:136:5)
16 verbose stack at async Init.exec (C:\Users\User\AppData\Roaming\npm\node_modules\npm\lib\commands\init.js:44:14)
16 verbose stack at async Npm.exec (C:\Users\User\AppData\Roaming\npm\node_modules\npm\lib\npm.js:207:9)
16 verbose stack at async module.exports (C:\Users\User\AppData\Roaming\npm\node_modules\npm\lib\cli\entry.js:74:5)
17 verbose pkgid [email protected]
18 error could not determine executable to run
19 verbose cwd C:\Users\User\Documents\_G\Source code\ATBA\wasm_example_2
20 verbose os Windows_NT 10.0.22631
21 verbose node v20.16.0
22 verbose npm v10.8.2
23 verbose exit 1
24 verbose code 1
25 error A complete log of this run can be found in: C:\Users\User\AppData\Local\npm-cache\_logs\2024-07-25T11_15_43_784Z-debug-0.log
Steps to Reproduce
This tutorial.
Expected Behavior
npm init wasm-app www creates www folder.
Actual Behavior
npm init wasm-app www fails.
I had a same problem!!!! but I found this solution that is working!
on your wasm-game-of-life directory,
- npm install -g create-wasm-app
- then make a package.json file in root dir (I mean the location of your project) and add this:
{
"dependencies": {
"create-wasm-app": "/usr/local/lib/node_modules/create-wasm-app"
}
}
- npm install
- npm init wasm-app www 🦀 Rust + 🕸 Wasm = ❤
{ "dependencies": { "create-wasm-app": "/usr/local/lib/node_modules/create-wasm-app" } }
still not working :(
I had a same problem!!!! but I found this solution that is working!
on your wasm-game-of-life directory,
npm install -g create-wasm-app
then make a package.json file in root dir (I mean the location of your project) and add this:
{ "dependencies": { "create-wasm-app": "/usr/local/lib/node_modules/create-wasm-app" } }
npm install
npm init wasm-app www 🦀 Rust + 🕸 Wasm = ❤
haha, thx. We need to replace {/usr/local/lib} with our own path, used npm prefix -g query
Solution given by @AshkanRamezani doesn't work in node v20.x , but its working fine in v18, Thanks.
@Imran-S-heikh Adding file: prefix works, my node is v22.
{
"dependencies": {
"create-wasm-app": "file:path/to/node_modules/create-wasm-app"
}
}
there is a new error after i done all recommendations above:
0 verbose cli C:\Program Files\nodejs\node.exe C:\Users\ASUS\AppData\Roaming\npm\node_modules\npm\bin\npm-cli.js
1 info using [email protected]
2 info using [email protected]
3 silly config load:file:C:\Users\ASUS\AppData\Roaming\npm\node_modules\npm\npmrc
4 silly config load:file:E:\Coding\Code\Wasm\wasm-game-of-life\.npmrc
5 silly config load:file:C:\Users\ASUS\.npmrc
6 silly config load:file:C:\Users\ASUS\AppData\Roaming\npm\etc\npmrc
7 verbose title npm init wasm-app
8 verbose argv "init" "wasm-app"
9 verbose logfile logs-max:10 dir:C:\Users\ASUS\AppData\Local\npm-cache\_logs\2024-09-07T06_27_07_268Z-
10 verbose logfile C:\Users\ASUS\AppData\Local\npm-cache\_logs\2024-09-07T06_27_07_268Z-debug-0.log
11 silly logfile start cleaning logs, removing 2 files
12 silly logfile done cleaning log files
13 silly packumentCache heap:4345298944 maxSize:1086324736 maxEntrySize:543162368
14 verbose shrinkwrap failed to load node_modules/.package-lock.json out of date, updated: C:/Users/ASUS/AppData/Roaming/npm/node_modules/create-wasm-app
15 verbose stack Error: command failed
15 verbose stack at promiseSpawn (C:\Users\ASUS\AppData\Roaming\npm\node_modules\npm\node_modules\@npmcli\promise-spawn\lib\index.js:22:22)
15 verbose stack at spawnWithShell (C:\Users\ASUS\AppData\Roaming\npm\node_modules\npm\node_modules\@npmcli\promise-spawn\lib\index.js:124:10)
15 verbose stack at promiseSpawn (C:\Users\ASUS\AppData\Roaming\npm\node_modules\npm\node_modules\@npmcli\promise-spawn\lib\index.js:12:12)
15 verbose stack at runScriptPkg (C:\Users\ASUS\AppData\Roaming\npm\node_modules\npm\node_modules\@npmcli\run-script\lib\run-script-pkg.js:77:13)
15 verbose stack at runScript (C:\Users\ASUS\AppData\Roaming\npm\node_modules\npm\node_modules\@npmcli\run-script\lib\run-script.js:9:12)
15 verbose stack at run (C:\Users\ASUS\AppData\Roaming\npm\node_modules\npm\node_modules\libnpmexec\lib\run-script.js:48:10)
15 verbose stack at async exec (C:\Users\ASUS\AppData\Roaming\npm\node_modules\npm\node_modules\libnpmexec\lib\index.js:298:10)
15 verbose stack at async Init.execCreate (C:\Users\ASUS\AppData\Roaming\npm\node_modules\npm\lib\commands\init.js:135:5)
15 verbose stack at async Init.exec (C:\Users\ASUS\AppData\Roaming\npm\node_modules\npm\lib\commands\init.js:44:14)
15 verbose stack at async Npm.exec (C:\Users\ASUS\AppData\Roaming\npm\node_modules\npm\lib\npm.js:207:9)
16 error code 1
17 error path E:\Coding\Code\Wasm\wasm-game-of-life
18 error command failed
19 error command C:\Windows\system32\cmd.exe /d /s /c create-wasm-app
20 verbose cwd E:\Coding\Code\Wasm\wasm-game-of-life
21 verbose os Windows_NT 10.0.22631
22 verbose node v20.10.0
23 verbose npm v10.8.3
24 verbose exit 1
25 verbose code 1
26 error A complete log of this run can be found in: C:\Users\ASUS\AppData\Local\npm-cache\_logs\2024-09-07T06_27_07_268Z-debug-0.log
you can clone this directly with:
git clone https://github.com/rustwasm/create-wasm-app.git www
I had a same problem!!!! but I found this solution that is working!
on your wasm-game-of-life directory,
npm install -g create-wasm-app
then make a package.json file in root dir (I mean the location of your project) and add this:
{ "dependencies": { "create-wasm-app": "/usr/local/lib/node_modules/create-wasm-app" } }
npm install
npm init wasm-app www 🦀 Rust + 🕸 Wasm = ❤
path of create-wasm-app can be found directly with npm list -g
It seems like this issue is caused by a bug in the package-json package, which npm depends on.
You can check the details here: https://github.com/npm/cli/issues/7728
Because of this bug, the bin field in this repository’s package.json isn't being read correctly.
You can see the relevant line here: https://github.com/rustwasm/create-wasm-app/blob/9ac3dff9ebea4675e5c478bcdcbc0fd547d1529f/package.json#L7
Although the bug has been fixed, the fix hasn't been merged into npm yet. It will likely be included in the next npm release.
As a temporary fix, I followed the pull request for the package-json package and manually changed '.' to './' in the installed npm. After making that change, running npm init wasm-app www worked successfully. You can find the relevant line to modify here:
https://github.com/npm/cli/blob/63d6a732c3c0e9c19fd4d147eaa5cc27c29b168d/node_modules/%40npmcli/package-json/lib/normalize.js#L132
finally it works! thanks buddy! @7crabs
Works with node 23.6.1 / npm 10.9.2
I was trying to follow the tutorial at link but it fails with Module parse failed: Unknown element type in table: 0xNaN.
I'm currently using WSL2 (5.15.167.4-microsoft-standard-WSL2 #1 SMP Tue Nov 5 00:21:55 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux)
The npm version is 10.9.2
The Node.js version is 22.17.0
Full error message
ERROR in ../pkg/wasm_game_of_life_bg.wasm
Module parse failed: Unknown element type in table: 0xNaN
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
Error: Unknown element type in table: 0xNaN
at new CompileError (/home/myuser/documents/rust/wasm-game-of-life/www/node_modules/@webassemblyjs/helper-api-error/lib/index.js:40:109)
at parseTableType (/home/myuser/documents/rust/wasm-game-of-life/www/node_modules/@webassemblyjs/wasm-parser/lib/decoder.js:984:13)
at parseTableSection (/home/myuser/documents/rust/wasm-game-of-life/www/node_modules/@webassemblyjs/wasm-parser/lib/decoder.js:1240:24)
at parseSection (/home/myuser/documents/rust/wasm-game-of-life/www/node_modules/@webassemblyjs/wasm-parser/lib/decoder.js:1375:25)
at Object.decode (/home/myuser/documents/rust/wasm-game-of-life/www/node_modules/@webassemblyjs/wasm-parser/lib/decoder.js:1696:25)
at decode (/home/myuser/documents/rust/wasm-game-of-life/www/node_modules/@webassemblyjs/wasm-parser/lib/index.js:248:21)
at WebAssemblyParser.parse (/home/myuser/documents/rust/wasm-game-of-life/www/node_modules/webpack/lib/wasm/WebAssemblyParser.js:74:19)
at /home/myuser/documents/rust/wasm-game-of-life/www/node_modules/webpack/lib/NormalModule.js:482:32
at /home/myuser/documents/rust/wasm-game-of-life/www/node_modules/webpack/lib/NormalModule.js:358:12
at /home/myuser/documents/rust/wasm-game-of-life/www/node_modules/loader-runner/lib/LoaderRunner.js:373:3
at iterateNormalLoaders (/home/myuser/documents/rust/wasm-game-of-life/www/node_modules/loader-runner/lib/LoaderRunner.js:214:10)
at Array.<anonymous> (/home/myuser/documents/rust/wasm-game-of-life/www/node_modules/loader-runner/lib/LoaderRunner.js:205:4)
at Storage.finished (/home/myuser/documents/rust/wasm-game-of-life/www/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:55:16)
at /home/myuser/documents/rust/wasm-game-of-life/www/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:91:9
at /home/myuser/documents/rust/wasm-game-of-life/www/node_modules/graceful-fs/graceful-fs.js:78:16
at FSReqCallback.readFileAfterClose [as oncomplete] (node:internal/fs/read/context:68:3)
@ ../pkg/wasm_game_of_life.js 1:0-52 4:15-19 5:0-21
@ ./index.js
@ ./bootstrap.js
ERROR in chunk 0
217696aecf5db819bdb3.module.wasm
/home/myuser/documents/rust/wasm-game-of-life/pkg/wasm_game_of_life_bg.wasm
unexpected end
Looks like this guy link created a nice workaround