Запутался в учебнике на веб-сайте «Rust ? и WebAssembly ?» - PullRequest
0 голосов
/ 28 мая 2019

Я попробовал Пример Hello World о ржавчине и веб-сборке здесь (на macbookpro 2018)

Но застрял на последнем шаге теста.

Я изменил index.js и package.json согласно учебному пособию

index.js

import * as wasm from "wasm-game-of-life";
wasm.greet();

пакет.json

"devDependencies": {
  "wasm-game-of-life": "file:../pkg",
  "hello-wasm-pack": "^0.1.0",
  "webpack": "^4.29.3",
  "webpack-cli": "^3.1.0",
  "webpack-dev-server": "^3.1.5",
  "copy-webpack-plugin": "^5.0.0"
}

Я также пытался добавить отдельную часть в package.json , как показано ниже

"dependencies": {
  "wasm-game-of-life": "file:../pkg"
}

К сожалению, они оба не работали.

Наборы инструментов, которые я использовал при прохождении примера

rustup 1.18.3
rustc 1.35.0
cargo 1.35.0
npm 6.9.0
node v10.15.3

Точное сообщение об ошибке ниже:

(base) ➜  www git:(master) npm run start

> create-wasm-app@0.1.0 start /Users/updrew/workspace/rust playground/wasm-game-of-life/www
> webpack-dev-server

ℹ 「wds」: Project is running at http://localhost:8080/
ℹ 「wds」: webpack output is served from /
ℹ 「wds」: Content not from webpack is served from /Users/updrew/workspace/rust playground/wasm-game-of-life/www
✖ 「wdm」: Hash: 2c7b176d8a66be382dd2
Version: webpack 4.32.2
Time: 332ms
Built at: 05/28/2019 11:13:57 AM
         Asset       Size  Chunks             Chunk Names
0.bootstrap.js  672 bytes       0  [emitted]
  bootstrap.js    354 KiB    main  [emitted]  main
    index.html  175 bytes          [emitted]
Entrypoint main = bootstrap.js
[0] multi (webpack)-dev-server/client?http://localhost ./bootstrap.js 40 bytes {main} [built]
[./bootstrap.js] 279 bytes {main} [built]
[./index.js] 57 bytes {0} [built]
[./node_modules/ansi-html/index.js] 4.16 KiB {main} [built]
[./node_modules/events/events.js] 13.3 KiB {main} [built]
[./node_modules/html-entities/index.js] 231 bytes {main} [built]
[./node_modules/loglevel/lib/loglevel.js] 7.68 KiB {main} [built]
[./node_modules/querystring-es3/index.js] 127 bytes {main} [built]
[./node_modules/url/url.js] 22.8 KiB {main} [built]
[./node_modules/webpack-dev-server/client/index.js?http://localhost] (webpack)-dev-server/client?http://localhost 9.26 KiB {main} [built]
[./node_modules/webpack-dev-server/client/overlay.js] (webpack)-dev-server/client/overlay.js 3.59 KiB {main} [built]
[./node_modules/webpack-dev-server/client/socket.js] (webpack)-dev-server/client/socket.js 1.05 KiB {main} [built]
[./node_modules/webpack-dev-server/node_modules/strip-ansi/index.js] (webpack)-dev-server/node_modules/strip-ansi/index.js 161 bytes {main} [built]
[./node_modules/webpack/hot sync ^\.\/log$] (webpack)/hot sync nonrecursive ^\.\/log$ 170 bytes {main} [built]
[./node_modules/webpack/hot/emitter.js] (webpack)/hot/emitter.js 75 bytes {main} [built]
    + 12 hidden modules

ERROR in ./index.js
Module not found: Error: Can't resolve 'wasm-game-of-life' in '/Users/updrew/workspace/rust playground/wasm-game-of-life/www'
 @ ./index.js 1:0-42 2:0-10
 @ ./bootstrap.js
ℹ 「wdm」: Failed to compile.
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...