pnpm tauri build 出现proxy错误

2024-03-16  本文已影响0人  Oct1a

代理设置全局也不行,后面发现给rust cargo设置代理即可
如果出现跟我一样的情况,可以试下,我改完之后就可以了

D:\xxxxx\xxxx>pnpm tauri build

> xxxx@0.0.0 tauri
> tauri "build"

     Running beforeBuildCommand `pnpm build`

> xxxxx@0.0.0 build 
> vite build

vite v5.1.6 building for production...
✓ 17 modules transformed.
dist/index.html                  0.48 kB │ gzip:  0.31 kB
dist/assets/index-Tn0Wq8gz.css   1.40 kB │ gzip:  0.66 kB
dist/assets/index-BP7kSTzz.js   57.74 kB │ gzip: 23.26 kB
✓ built in 627ms
    Updating crates.io index
warning: spurious network error (3 tries remaining): [5] Couldn't resolve proxy name (Unsupported proxy syntax in ''http://127.0.0.1:7890'': Port number was not a decimal number between 0 and 65535)
warning: spurious network error (2 tries remaining): [5] Couldn't resolve proxy name (Unsupported proxy syntax in ''http://127.0.0.1:7890'': Port number was not a decimal number between 0 and 65535)
warning: spurious network error (1 tries remaining): [5] Couldn't resolve proxy name (Unsupported proxy syntax in ''http://127.0.0.1:7890'': Port number was not a decimal number between 0 and 65535)
error: failed to get `serde` as a dependency of package `haolin v0.0.0 (D:\Project\haolingjiancai\haolin\src-tauri)`

Caused by:
  failed to query replaced source registry `crates-io`

Caused by:
  download of config.json failed

Caused by:
  failed to download from `https://index.crates.io/config.json`

Caused by:cargo update
  [5] Couldn't resolve proxy name (Unsupported proxy syntax in ''http://127.0.0.1:7890'': Port number was not a decimal number between 0 and 65535)
       Error failed to build app: failed to build app
 ELIFECYCLE  Command failed with exit code 1.

如果出现该错误,cd进入项目的src-tauri文件夹,运行cargo update

    Updating crates.io index
warning: spurious network error (3 tries remaining): [5] Couldn't resolve proxy name (Unsupported proxy syntax in ''http://127.0.0.1:7890'': Port number was not a decimal number between 0 and 65535)
warning: spurious network error (2 tries remaining): [5] Couldn't resolve proxy name (Unsupported proxy syntax in ''http://127.0.0.1:7890'': Port number was not a decimal number between 0 and 65535)
warning: spurious network error (1 tries remaining): [5] Couldn't resolve proxy name (Unsupported proxy syntax in ''http://127.0.0.1:7890'': Port number was not a decimal number between 0 and 65535)
error: failed to get `serde` as a dependency of package `haolin v0.0.0 (D:\Project\haolingjiancai\haolin\src-tauri)`

会发现出现同样的错误

这时候只要在 C:\Users\用户名.cargo 下创建 config 文件(可以先创建config.txt文件,填充内容后删除后缀)
内容设置

[http]
proxy = "127.0.0.1:7890"

[https]
proxy = "127.0.0.1:7890"

现在重新运行会发现就正常了

第一次用tauri,发现好多错误Google都找不到....

上一篇 下一篇

猜你喜欢

热点阅读