Error while trying out WebAssembly

I'm trying out WebAssembly, and I'm stuck at the following:

On this page:
https://rustwasm.github.io/book/game-of-life/hello-world.html

in the section "Using our Local wasm-game-of-life Package in www"...

it asked me to add to "dependencies" in the "package.json" file:

{
  // ...
  "dependencies": {
    "wasm-game-of-life": "file:../pkg", // Add this line!
    // ...
  }
}

First, I cannot find "dependencies", but could find "devDependencies".

Second, what exactly should the value be "file:../pkg" (I mean should the "..." be replaced with some actual parameters)

And, it generates the following error:

npm ERR! code EJSONPARSE
npm ERR! file /Users/ikevin/Desktop/wasm3/wasm-game-of-life/www/package.json
npm ERR! JSON.parse Failed to parse json
npm ERR! JSON.parse Unexpected string in JSON at position 937 while parsing '{
npm ERR! JSON.parse "name": "create-wasm-app",
npm ERR! JSON.parse "versio'
npm ERR! JSON.parse Failed to parse package.json data.
npm ERR! JSON.parse package.json must be actual JSON, not just JavaScript.

Please help. Thanks!

EJSONPARSE is about mere syntax error in package.json. It hasn't even looked at the dependencies yet, it choked on a comma.

"wasm-game-of-life": "file:../pkg",
                                  ^ remove this

The example assumed you'd have another item after it, so the comma would be necessary, but you don't, so JSON completely freaks out and stops the world, because of that one unnecessary comma there.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.