关于“error when starting dev server:Error: The package “@esbuild/win32-x64“ could not be found”的错误

关于vue3+vite+typescript项目中出现“Error: The package "@esbuild/win32-x64" could not be found, and is needed by esbuild.”的错误

此问题出现在运行vue-cli项目中

使用vite创建项目,启动yarn dev时报错

问题截图如下

意思是说: 

无法从...\vite.config.ts加载配置

启动dev服务器时出错:

错误:找不到包“@ebuild/win32-x64”,该包是esbuild所必需的。

如果使用npm安装esbuild,请确保没有指定

“--no optional”或“--省略=可选”标志。“可选依赖项”功能

的“package.json”被esbuild用来安装正确的二进制可执行文件

针对您当前的平台

解决方案

在运行dev之前先运行node node_modules/esbuild/install.js命令来解决esbuild安装问题;如下:

然后再启动项目,发现已经能正常运行 

 

  • 6
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
failed to load config from D:\朗慧\digital-welcome-project\vite.config.ts error when starting dev server: Error: You installed esbuild for another platform than the one you're currently using. This won't work because esbuild is written with native code and needs to install a platform-specific binary executable. Specifically the "@esbuild/win32-x64" package is present but this platform needs the "@esbuild/win32-ia32" package instead. People often get into this situation by installing esbuild on Windows or macOS and copying "node_modules" into a Docker image that runs Linux, or by copying "node_modules" between Windows and WSL environments. If you are installing with npm, you can try not copying the "node_modules" directory when you copy the files over, and running "npm ci" or "npm install" on the destination platform after the copy. Or you could consider using yarn instead of npm which has built-in support for installing a package on multiple platforms simultaneously. If you are installing with yarn, you can try listing both this platform and the other platform in your ".yarnrc.yml" file using the "supportedArchitectures" feature: https://yarnpkg.com/configuration/yarnrc/#supportedArchitectures Keep in mind that this means multiple copies of esbuild will be present. Another alternative is to use the "esbuild-wasm" package instead, which works the same way on all platforms. But it comes with a heavy performance cost and can sometimes be 10x slower than the "esbuild" package, so you may also not want to do that.
06-06
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值