[vite] spawn esbuild.exe ENOENT 报错

对应的 GitHub issue:Error: spawn C:\..\node_modules\esbuild\esbuild.exe ENOENT · Issue #1361 · vitejs/vite · GitHub

在搭建过程中运行得好好的,突然安装了vuex之后,再重新运行 yarn dev 就报错了,整得我一脸懵逼,风中凌乱。

于是我去找 Vite 的官方文档:https://github.com/vitejs/vite,去 issue 中搜索关键词 spawn esbuild.exe,果然有对应的 issue。

尤雨溪的回复:

Check npm config get ignore-scripts. Your npm config seems to ignore esbuild's postinstall hook.
If that's not the problem, try installing esbuild directly in a fresh project - if that doesn't work also, then it's a esbuild bug and should be reported to esbuild instead.
大意是,先检查npm的配置,npm config get ignore-scripts,如果还是不行,就重新安装 esbuild:node ./node_modules/esbuild/install.js。


Abiel的回复:

It turns out npm v7 has a bug that corrupts package-lock.json files: npm/cli#2606. When this happens, packages like esbuild with post install scripts can break. You may be experiencing this bug. A workaround is to delete and recreate your package-lock.json file.
大意是,应该删除 package-lock.json 文件,重新安装。

我的解决步骤如下:

  1. 重置npm ignore-scripts配置: npm config set ignore-scripts false,无效;
  2. 重新安装: node ./node_modules/esbuild/install.js,有效;
  3. 顺便把 yarn.lock 文件删了,重新安装。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值