我在这里尝试过Hello World Example关于锈和网络装配的问题(在macbookpro 2018上)
但是在最后的测试步骤中卡住了。
我根据教程更改了 index.js 和 package.json
index.js
import * as wasm from "wasm-game-of-life";
wasm.greet();
package.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.
答案 0 :(得分:0)
它看起来像这样:
"dependencies": {
"wasm-game-of-life": "file:../pkg",
"copy-webpack-plugin": "^5.0.0",
"webpack": "^4.16.3",
"webpack-cli": "^3.1.0",
"webpack-dev-server": "^3.1.5"
}