Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[4.2] greet keeps saying "Hello, wasm-game-of-life!" #289

Open
undavide opened this issue Feb 19, 2023 · 1 comment
Open

[4.2] greet keeps saying "Hello, wasm-game-of-life!" #289

undavide opened this issue Feb 19, 2023 · 1 comment

Comments

@undavide
Copy link

Describe the bug
Following the 4.2 exercise solution at the bottom of the page, the greet() keeps alerting Hello, wasm-game-of-life! instead of Hello, Davide!.

To Reproduce
I've followed the tutorial I believe to the letter. To solve the final exercise, I've implemented wasm-game-of-life/src/lib.rs as:

#[wasm_bindgen]
pub fn greet(name: &str) {
    alert(&format!("Hello, {}!", name));
}

Also wasm-game-of-life/www/index.js now contains:

wasm.greet("Davide");

I've then run wasm-pack build to rebuild the wasm package, and to be 100% sure, I've closed and re-opened the local server via npm run start.

Expected behavior
http://localhost:8080 should pop up an alert saying Hello, Davide!, instead it keeps saying Hello, wasm-game-of-life!

I've made sure that package.json contains the "dependencies": { "wasm-game-of-life": "file:../pkg" }, and npm install has run thereafter.

Additional context
rustc 1.66.0, wasm-bindgen 0.2.63.

Thank you!

@undavide
Copy link
Author

undavide commented Feb 20, 2023

I've found a crucial bit of information in this page from the wasm-pack docs:

Go into the package.json file, add your package, and remove the hello-wasm-pack dependency from the "dependencies" section.

I've then deleted the entire node_modules folder and run npm install once more. I'd suggest to add it to the documentation.
Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant