question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

🐛 BUG: Could not resolve errors when using WASM on Windows

See original GitHub issue

What version of Wrangler are you using?

0.0.0-859d6e7

What operating system are you using?

Windows

Describe the Bug

Whilst trying out the new WASI on workers, I was unable to use the new feature on Windows. I believe this is a Windows-specific issue, as it did not occur when using the exact same command with the exact same WASM file on WSL.

Windows NodeJS version: v16.15.0 WSL NodeJS version: v16.16.0

When running

npx wrangler@wasm dev target/wasm32-wasi/release/wasmtest.wasm

on Windows, it prints out the following error:

X [ERROR] Could not resolve "....\npm-cache_npxab8cfd027326cb55\node_modules@cloudflareworkers-wasidistindex.mjs"

    ../../../AppData/Local/Temp/tmp-31516-jZOY6EVYFut2/index.mjs:2:21:
      2 │ import { WASI } from '..\..\npm-cache\_npx\ab8cfd027326cb55\node_modules\@cloudflare\workers-wasi\dist\index.mjs';
        ╵                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

  You can mark the path
  "....\npm-cache_npxab8cfd027326cb55\node_modules@cloudflareworkers-wasidistindex.mjs" as external
  to exclude it from the bundle, which will remove this error.

X [ERROR] Could not resolve "........Documentscodewasmtest\targetwasm32-wasi\releasewasmtest.wasm"

    ../../../AppData/Local/Temp/tmp-31516-jZOY6EVYFut2/index.mjs:3:17:
      3 │ import wasm from '..\..\..\..\Documents\code\wasmtest\target\wasm32-wasi\release\wasmtest.wasm';
        ╵                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

  You can mark the path "........Documentscodewasmtest\targetwasm32-wasi\releasewasmtest.wasm" as
  external to exclude it from the bundle, which will remove this error.


X [ERROR] Build failed with 2 errors:

  ../../../AppData/Local/Temp/tmp-31516-jZOY6EVYFut2/index.mjs:2:21: ERROR: Could not resolve
  "....\npm-cache_npxab8cfd027326cb55\node_modules@cloudflareworkers-wasidistindex.mjs"
  ../../../AppData/Local/Temp/tmp-31516-jZOY6EVYFut2/index.mjs:3:17: ERROR: Could not resolve
  "........Documentscodewasmtest\targetwasm32-wasi\releasewasmtest.wasm"

The root of the Rust project I used to test this is in C:\Users\zegevlier\Documents\code\wasmtest.

I also tried it in the root of the directory containing the .wasm file, but this also did not work and produced a similar error. This, again, worked perfectly as expected in WSL.

npx wrangler@wasm dev .\wasmtest.wasm

Hope this helps, please let me know if you need additional information.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
zegevliercommented, Jul 7, 2022

Seems to work for me! I’m very pleasantly surprised at how quickly this was resolved, thank you! Now I don’t have to hassle with WSL 😄

1reaction
threepointonecommented, Jul 7, 2022

Thanks so much for digging in! I’m afk at the moment, will get back to this in a couple of hours

Read more comments on GitHub >

github_iconTop Results From Across the Web

Wasm build doesn't work on Windows · Issue #687 - GitHub
Running a build on Windows doesn't work when using the esbuild-wasm package. It works fine when using esbuild (but we'd prefer to avoid...
Read more >
Weird errors problem with dotnet watch with blazor/wasm.
The watch windows reports an error that dll cannot be found. This happens due to the initial build error. At this point, if...
Read more >
Blazor error Type or namespace name 'App' could not be found
The error suggests the project can't find App.razor . Try fully qualifying it in either program.cs for WASM or _hosts.html in Server. –...
Read more >
API - esbuild
API. The API can be accessed in one of three ways: on the command line, in JavaScript, and in Go. The concepts and...
Read more >
Compiling from Rust to WebAssembly - MDN Web Docs
Not everything is supported yet, but we're working on it. Please file bugs if something is missing. Producing Rust functions that JavaScript can...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found