rustwasm / create-wasm-app

npm init template for consuming rustwasm pkgs
https://www.npmjs.com/package/create-wasm-app
Apache License 2.0
502 stars 93 forks source link

`npm init wasm-app www` fails #213

Open yeheshuah opened 3 months ago

yeheshuah commented 3 months ago

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 npm@10.8.2
2 info using node@v20.16.0
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 create-wasm-app@0.1.0
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.

AshkanRamezani commented 3 months ago

I had a same problem!!!! but I found this solution that is working!

on your wasm-game-of-life directory,

1) npm install -g create-wasm-app


2) 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"
  }
}

3) npm install


4) npm init wasm-app www 🦀 Rust + 🕸 Wasm = ❤

woshishabii commented 3 months ago

{ "dependencies": { "create-wasm-app": "/usr/local/lib/node_modules/create-wasm-app" } }

still not working :(

wangsj1018 commented 3 months ago

I had a same problem!!!! but I found this solution that is working!

on your wasm-game-of-life directory,

  1. npm install -g create-wasm-app

  2. 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"
  }
}
  1. npm install

  2. 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

Imran-S-heikh commented 2 months ago

Solution given by @AshkanRamezani doesn't work in node v20.x , but its working fine in v18, Thanks.

Fancyflame commented 2 months ago

@Imran-S-heikh Adding file: prefix works, my node is v22.

{
  "dependencies": {
    "create-wasm-app": "file:path/to/node_modules/create-wasm-app"
  }
}
Jnternet commented 2 months ago

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 npm@10.8.3
2 info using node@v20.10.0
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
AlbericoD commented 2 months ago

you can clone this directly with:

git clone https://github.com/rustwasm/create-wasm-app.git www

CanglongCl commented 1 month ago

I had a same problem!!!! but I found this solution that is working!

on your wasm-game-of-life directory,

  1. npm install -g create-wasm-app

  2. 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"
  }
}
  1. npm install

  2. npm init wasm-app www 🦀 Rust + 🕸 Wasm = ❤

path of create-wasm-app can be found directly with npm list -g

7crabs commented 1 month ago

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