Estoy aprendiendo los fundamentos del ensamblaje web usando rust y estoy siguiendo este tutorial . Funcionó bien para todas las cosas, excepto al importar el código javascript del ensamblado web donde da este error,
La carga falló para el módulo con la fuente "http://localhost:8000/pkg/hello_wasm.js".
Intenté deshabilitar todas las extensiones de terceros y lo volví a intentar, pero recibo el mismo error.
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <title>Hello Wasm!</title> <script type="module"> import init, { add } from './pkg/hello_wasm.js' await init() // this loads and instantiates our WASM module console.log(add(1, 2)) // this calls our compiled Rust function! </script> </head> <body></body> </html> └── App/ ├── pkg/ │ ├── hello_wasm_bg.wasm │ ├── hello_wasm.js │ ├── some _ other _ files │ └── index.html └── src/ └── lib.rsTiene index.html en su carpeta pkg , por lo que cuando importe el archivo js como ./pkg/... buscará una carpeta llamada pkg dentro de pkg . Mueva index.html hacia arriba en un directorio (y reinicie el servidor desde la carpeta de la App ) o cambie la importación a ./hello_wasm.js para que esto funcione correctamente.
└── App/ ├── index.html ├── pkg/ │ ├── hello_wasm_bg.wasm │ ├── hello_wasm.js │ └── some _ other _ files └── src/ └── lib.rs