WASM /紫杉-无法解决:在`os`

问题描述

在Windows上构建Yew应用程序

以下是我在Windows上与火箭后端一起构建的紫杉应用程序 this tutorial (尽管本教程适用于Linux环境)。我正在尝试构建紫杉应用程序 使用wasm-pack。不过,我没有使用Linux子系统来构建应用程序 我已经安装了。

代码/配置

The repository

我已经安装了wasm工具链和货运工具:

rustup target add wasm32-unkNown-unkNown

以下是我的工具链列表:

stable-x86_64-pc-windows-gnu
stable-x86_64-pc-windows-msvc
nightly-x86_64-pc-windows-msvc (default)
1.30.0-x86_64-pc-windows-msvc

这是我的文件夹结构:

Project root
├───backend           <-- rocket backend
|   ├───Cargo.toml
│   └───src
│       ├───bin
│       └───db
├───frontend          <-- yew frontend
│   ├───pkg
│   ├───src
|   ├───Cargo.toml
|   └───Makefile.toml
├───src
├───Cargo.toml
└───Makefile.toml

这是rootdir\Cargo.toml

[package]
name = "sentinel"
version = "0.1.0"
authors = ["zachdelano <email>"]
edition = "2018"

[workspace]
members = ["backend","frontend"]

这是rootdir\Makefile.toml

[env]
CARGO_MAKE_EXTEND_WORKSPACE_MAKEFILE = "true"

[tasks.default]
clear = true
dependencies = ["build"]

这是rootdir\frontend\Cargo.toml

[dependencies]
sentinel = { path = ".." }
yew = "0.17.3"
wasm-pack = "0.9.1"
wasm-bindgen = "0.2.68"
web-sys = "0.3.45"

[lib]
crate-type = ["cdylib","rlib"]

这是rootdir\frontend\Makefile.toml

[tasks.default]
dependencies = ["create_wasm"]

[tasks.create_wasm]
command = "wasm-pack"
args = ["build","--target","web","--out-name","package","--dev"] 
dependencies = ["build"]

预期结果

我希望该应用在运行时能够顺利完成构建 cargo makeYew tutorial 似乎表明没有其他需要。

实际输出

(从根目录)运行cargo make时,出现很多错误,如下所示:

error[E0433]: Failed to resolve: Could not find `unix` in `os`
  --> C:\Users\Zach\.cargo\registry\src\github.com-1ecc6299db9ec823\dirs-1.0.5\src\lin.rs:41:18
   |
41 |     use std::os::unix::ffi::OsstringExt;
   |                  ^^^^ Could not find `unix` in `os`

请参见the entire list of errors

这是工具链之类的东西吗?我该如何解决

正在运行rustup update

我得到the following output 运行rustup update

现在,当我从根目录运行cargo make时,会出现不同的错误

error[E0432]: unresolved import `crate::sys`                                                                                                                                                                                     
  --> C:\Users\Zach\.cargo\registry\src\github.com-1ecc6299db9ec823\socket2-0.3.15\src\socket.rs:23:5
   |
23 | use crate::sys;
   |     ^^^^^^^^^^ no `sys` in the root

请参见full list of errors。 部分代码已更改in the repository

解决方法

问题最终导致我试图安装wasm-packweb-sys。我不知道为什么会这样,但是当我注释掉它们并运行cargo make时,一切都构建良好。我还删除了target,然后重新运行cargo make以确保。

[package]
name = "frontend"
version = "0.1.0"
authors = ["zachdelano <email>"]
edition = "2018"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
sentinel = { path = ".." }
yew = "0.17.3"
wasm-bindgen = "0.2.68"
# wasm-pack = "0.9.1"
# web-sys = "0.3.45"

[lib]
crate-type = ["cdylib","rlib"]

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...