创建第一个rust tauri项目

发布于:2024-08-08 ⋅ 阅读:(106) ⋅ 点赞:(0)

安装nodejs

curl -sL https://deb.nodesource.com/setup_20.x | sudo bash
node -v
proxychains4 npm create tauri-app@latest
✔ Project name · tauri-app
✔ Choose which language to use for your frontend · TypeScript / JavaScript - (pnpm, yarn, npm, bun)
✔ Choose your package manager · npm
✔ Choose your UI template · React - (https://react.dev/)
✔ Choose your UI flavor · JavaScript

Template created! To get started run:
  cd tauri-app
  npm install
  npm run tauri dev

由于wsl2会遇到渲染相关的报错,切换到windows。
windows包管理器安装nodejs。
https://nodejs.org/en/download/package-manager

# installs fnm (Fast Node Manager)
winget install Schniz.fnm --proxy "http://xxx:7890" --location "D:\winget"
# 创建$profile文件:粘贴到powershell后,按回车
if (!(Test-Path -Path $PROFILE)) {
    New-Item -ItemType File -Path $PROFILE -Force
}
# 更改配置文件
notepad $profile
# 在打开的notepad中,粘贴以下代码,并保存
fnm env --use-on-cd | Out-String | Invoke-Expression
# 重新用管理员身份开启powershell
# 让$profile可以被读取,更改权限
set-ExecutionPolicy RemoteSigned

# download and install Node.js
fnm use --install-if-missing 20
# verifies the right Node.js version is in the environment
node -v # should print `v20.16.0`
# verifies the right npm version is in the environment
npm -v # should print `10.8.1`

powershell设置代理

解决网络问题。

$env:HTTPS_PROXY="http://127.0.0.1:7890"
$env:HTTP_PROXY="http://127.0.0.1:7890"

网站公告

今日签到

点亮在社区的每一天
去签到