Rust & Wasm 初始设置
Rust & Wasm intitial set up
我正在关注 this tutorial 使用 rust 创建一个 webassembly 应用程序,但是当我尝试 运行 捆绑的 web assembly 代码与节点时(在添加我自己的任何代码之前并遵循完全教程)
$ npm run start
> create-wasm-app@0.1.0 start /Users/jakearmendariz/Desktop/wasm/wasm-game-of-life/www
> webpack-dev-server
/Users/jakearmendariz/Desktop/wasm/wasm-game-of-life/www/node_modules/copy-webpack-plugin/node_modules/schema-utils/dist/validate.js:98
throw new _ValidationError.default(errors, schema, configuration);
^
ValidationError: Invalid options object. Copy Plugin has been initialized using an options object that does not match the API schema.
- options[0] should be an object:
object { patterns, options? }
at validate (/Users/jakearmendariz/Desktop/wasm/wasm-game-of-life/www/node_modules/copy-webpack-plugin/node_modules/schema-utils/dist/validate.js:98:11)
at new CopyPlugin (/Users/jakearmendariz/Desktop/wasm/wasm-game-of-life/www/node_modules/copy-webpack-plugin/dist/index.js:32:30)
at Object.<anonymous> (/Users/jakearmendariz/Desktop/wasm/wasm-game-of-life/www/webpack.config.js:12:5)
at Module._compile (internal/modules/cjs/loader.js:776:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
at Module.require (internal/modules/cjs/loader.js:690:17)
at require (internal/modules/cjs/helpers.js:25:18)
at WEBPACK_OPTIONS (/Users/jakearmendariz/Desktop/wasm/wasm-game-of-life/www/node_modules/webpack-cli/bin/utils/convert-argv.js:114:13)
at requireConfig (/Users/jakearmendariz/Desktop/wasm/wasm-game-of-life/www/node_modules/webpack-cli/bin/utils/convert-argv.js:116:6)
at /Users/jakearmendariz/Desktop/wasm/wasm-game-of-life/www/node_modules/webpack-cli/bin/utils/convert-argv.js:123:17
at Array.forEach (<anonymous>)
at module.exports (/Users/jakearmendariz/Desktop/wasm/wasm-game-of-life/www/node_modules/webpack-cli/bin/utils/convert-argv.js:121:15)
at Object.<anonymous> (/Users/jakearmendariz/Desktop/wasm/wasm-game-of-life/www/node_modules/webpack-dev-server/bin/webpack-dev-server.js:84:40)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! create-wasm-app@0.1.0 start: `webpack-dev-server`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the create-wasm-app@0.1.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/jakearmendariz/.npm/_logs/2020-09-11T04_46_27_442Z-debug.log
webpack.config
const CopyWebpackPlugin = require("copy-webpack-plugin");
const path = require('path');
module.exports = {
entry: "./bootstrap.js",
output: {
path: path.resolve(__dirname, "dist"),
filename: "bootstrap.js",
},
mode: "development",
plugins: [
new CopyWebpackPlugin(['index.html'])
],
};
package.json 依赖关系
"dependencies": {
"minimist": "^1.2.5",
"wasm-game-of-life": "file:../pkg"
},
"devDependencies": {
"copy-webpack-plugin": "^6.1.0",
"hello-wasm-pack": "^0.1.0",
"webpack-cli": "^3.1.0",
"webpack-dev-server": "^3.11.0"
}
我完全按照以前的方式重新编写了教程,并且得到了相同的结果。我假设我的 npm 设置有问题,但我不确定。
当我从教程文件中指定的版本更新 copy-webpack-plugin 版本时,由于安全警报,我遇到了类似的错误。配置参数的格式同时改变了,所以我不得不改变它们以匹配。
教程有 "copy-webpack-plugin": "^5.0.3"
,我升级到 "copy-webpack-plugin": "^6.0.3"
,在 webpack.config.js
中我不得不更改
new CopyPlugin([
path.resolve(__dirname, "static")
]),
new CopyPlugin({
patterns: [
path.resolve(__dirname, "static")
]
}),
我不熟悉 webpack 或 copy-webpack-plugin 除了通过您正在学习的相同 rust-wasm 教程,所以使用此建议需要您自担风险;我只能说它似乎有效。
我在尝试从同一个 tutorial
运行 npm run start
时遇到了类似的错误
我的错误是没有 Node.js 的 LTS 版本,而是最新的。
- 我完全删除了我的 Node.js following theses steps
- 并安装了 safe LTS
我正在关注 this tutorial 使用 rust 创建一个 webassembly 应用程序,但是当我尝试 运行 捆绑的 web assembly 代码与节点时(在添加我自己的任何代码之前并遵循完全教程)
$ npm run start
> create-wasm-app@0.1.0 start /Users/jakearmendariz/Desktop/wasm/wasm-game-of-life/www
> webpack-dev-server
/Users/jakearmendariz/Desktop/wasm/wasm-game-of-life/www/node_modules/copy-webpack-plugin/node_modules/schema-utils/dist/validate.js:98
throw new _ValidationError.default(errors, schema, configuration);
^
ValidationError: Invalid options object. Copy Plugin has been initialized using an options object that does not match the API schema.
- options[0] should be an object:
object { patterns, options? }
at validate (/Users/jakearmendariz/Desktop/wasm/wasm-game-of-life/www/node_modules/copy-webpack-plugin/node_modules/schema-utils/dist/validate.js:98:11)
at new CopyPlugin (/Users/jakearmendariz/Desktop/wasm/wasm-game-of-life/www/node_modules/copy-webpack-plugin/dist/index.js:32:30)
at Object.<anonymous> (/Users/jakearmendariz/Desktop/wasm/wasm-game-of-life/www/webpack.config.js:12:5)
at Module._compile (internal/modules/cjs/loader.js:776:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
at Module.require (internal/modules/cjs/loader.js:690:17)
at require (internal/modules/cjs/helpers.js:25:18)
at WEBPACK_OPTIONS (/Users/jakearmendariz/Desktop/wasm/wasm-game-of-life/www/node_modules/webpack-cli/bin/utils/convert-argv.js:114:13)
at requireConfig (/Users/jakearmendariz/Desktop/wasm/wasm-game-of-life/www/node_modules/webpack-cli/bin/utils/convert-argv.js:116:6)
at /Users/jakearmendariz/Desktop/wasm/wasm-game-of-life/www/node_modules/webpack-cli/bin/utils/convert-argv.js:123:17
at Array.forEach (<anonymous>)
at module.exports (/Users/jakearmendariz/Desktop/wasm/wasm-game-of-life/www/node_modules/webpack-cli/bin/utils/convert-argv.js:121:15)
at Object.<anonymous> (/Users/jakearmendariz/Desktop/wasm/wasm-game-of-life/www/node_modules/webpack-dev-server/bin/webpack-dev-server.js:84:40)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! create-wasm-app@0.1.0 start: `webpack-dev-server`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the create-wasm-app@0.1.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/jakearmendariz/.npm/_logs/2020-09-11T04_46_27_442Z-debug.log
webpack.config
const CopyWebpackPlugin = require("copy-webpack-plugin");
const path = require('path');
module.exports = {
entry: "./bootstrap.js",
output: {
path: path.resolve(__dirname, "dist"),
filename: "bootstrap.js",
},
mode: "development",
plugins: [
new CopyWebpackPlugin(['index.html'])
],
};
package.json 依赖关系
"dependencies": {
"minimist": "^1.2.5",
"wasm-game-of-life": "file:../pkg"
},
"devDependencies": {
"copy-webpack-plugin": "^6.1.0",
"hello-wasm-pack": "^0.1.0",
"webpack-cli": "^3.1.0",
"webpack-dev-server": "^3.11.0"
}
我完全按照以前的方式重新编写了教程,并且得到了相同的结果。我假设我的 npm 设置有问题,但我不确定。
当我从教程文件中指定的版本更新 copy-webpack-plugin 版本时,由于安全警报,我遇到了类似的错误。配置参数的格式同时改变了,所以我不得不改变它们以匹配。
教程有 "copy-webpack-plugin": "^5.0.3"
,我升级到 "copy-webpack-plugin": "^6.0.3"
,在 webpack.config.js
中我不得不更改
new CopyPlugin([
path.resolve(__dirname, "static")
]),
new CopyPlugin({
patterns: [
path.resolve(__dirname, "static")
]
}),
我不熟悉 webpack 或 copy-webpack-plugin 除了通过您正在学习的相同 rust-wasm 教程,所以使用此建议需要您自担风险;我只能说它似乎有效。
我在尝试从同一个 tutorial
运行npm run start
时遇到了类似的错误
我的错误是没有 Node.js 的 LTS 版本,而是最新的。
- 我完全删除了我的 Node.js following theses steps
- 并安装了 safe LTS