emscripten-core / emscripten-core/emscripten

Failed to load resource

Open
#23,949 5 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
27.6k
Forks
3.6k
Avg merge
1d 1h
Merged PRs (30d)
105

Description

Please include the following in your bug report:

**Version of emscripten/emsdk:**

```console
$ emcc -v
emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 4.0.5-git (53b38d0c6f9fce1b62c55a8012bc6477f7a42711)
clang version 21.0.0git
Target: wasm32-unknown-emscripten
Thread model: posix
InstalledDir: C:/msys64/clang64/opt/emscripten-llvm/bin
```

**Failing command line in full:**

I was just customize [Using files](https://emscripten.org/docs/getting_started/Tutorial.html#using-files) example
from `Emscripten Tutorial` page:

```
$ mkdir -p out/static
$ ./emcc test/hello_world_file.cpp -o out/static/hello.mjs --preload-file test/hello_world_file.txt
$ cat > out/index.html << EOL


import initModule from './static/hello.mjs';
initModule({
print: (text) => { document.body.innerText += text + '\n'; }
});

EOL
$ ./emrun out/index.html
```

Failure from browser console:
```console
Failed to load resource: the server responded with a status of 404 (File not found: /out/hello.data)
```

Module `hello.mjs` search `hello.data` in `out` subdirectory (local webserver root). But `hello.mjs` sould search `hello.data` from `./static/` supdirecotry where `hello.mjs` hosted himself.

Then we mode `hello.data` to `out` from `out/static` and run again:

```console
$ mv out/static/hello.data out/
$ ./emrun out/index.html
```

And see text in browser:

```txt
==
This data has been read from a file.
The file is readable as if it were at the same location in the filesystem, including directories, as in the local filesystem where you compiled the source.
==
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.