rustwasm / book

The Rust and WebAssembly Book
https://rustwasm.github.io/docs/book/
MIT License
1.73k stars 208 forks source link

"Getting Started" step missing? #250

Open mvolkmann opened 3 years ago

mvolkmann commented 3 years ago

Where in the docs did you come across this?

Exercises at the end of section 4.2 "Hello, World!"

Describe what about it does not make sense

After making the suggested changes to src/lib.rs and www/index.js, running wasm-pack build, and refreshing the browser, I still see "Hello, hello-wasm-pack" and not the expected greeting. I tried deleting the target directory, running wasm-pack build again, and re-rerunning npm run build and npm run start, but I can't get my changes to have any effect. Is there a missing step?

Why does it not make sense?

I can't get the expected result.

How could we improve it?

Supply the missing step(s) if there are any.

blazzy commented 2 years ago

@mvolkmann , You may have missed one of the steps in this section. You likely need to:

  1. Update the package.json with a dependency pointing to the local wasm package built in ../pkg.
  2. Update the index.js file to import that package.

I missed the second step on my own first run through and it took me a while to realize the module I was importing in index.js was some module from npm and not the local package.

mfirgo commented 1 year ago

I've run into the same issue. The problem was that npm install did not reinstall wasm-game-of-life package.
Solution: Delete node_modules directory, then run npm install.
Alternatively you can run npm ci, which does the same thing.