Command “npm run build” exited with 126 Vercel.

huangapple go评论113阅读模式
英文:

Command «npm run build» exited with 126 Vercel

问题

我尝试使用Webpack将我的网站从存储库上传到Vercel,但在构建时出现以下错误:

跳过构建缓存,部署触发了无缓存。
克隆完成:2.089秒
运行 "vercel build"
Vercel CLI 31.2.3
安装依赖...
在 293ms 内更新
有15个软件包正在寻找资金支持
运行 `npm fund` 获取详细信息
检测到由npm 7+生成的 `package-lock.json`...
运行 "npm run build"

sh: /vercel/path0/node_modules/.bin/webpack: 权限被拒绝
错误:命令 "npm run build" 退出,代码为 126

当我在VS Code终端中键入 "npm run build" 时一切正常。我已尝试删除 node_modules 文件夹并重新安装 webpack,但没有成功。T_T

英文:

I try to upload my website with Webpack to Vercel from repository but I get this Error on build time:

Skipping build cache, deployment was triggered without cache.
Cloning completed: 2.089s
Running "vercel build"
Vercel CLI 31.2.3
Installing dependencies...
up to date in 293ms
15 packages are looking for funding
  run `npm fund` for details
Detected `package-lock.json` generated by npm 7+...
Running "npm run build"

sh: /vercel/path0/node_modules/.bin/webpack: Permission denied
Error: Command "npm run build" exited with 126

Everything is okay when I type "npm run build" in VS Code terminal. I've tried deleting node_modules folder and installing webpack again and it didn't work. T_T

答案1

得分: 1

更新命令使用sudo。在vercel中,需要超级用户权限。

sudo npm run build

或者无论您使用什么命令来执行vercel构建,都可以使用sudo执行。

例如:

sudo npm run dev
sudo npm run vercelbuild

等等。

这将解决您的问题。

英文:

Update the command with sudo. It seems in the vercel It required super user permission.

sudo npm run build

Or whatever command you use to execute vercel build, Just execute that with sudo.
eg.

sudo npm run dev
sudo npm run vercelbuild

and so on.

This will solve your problem.

huangapple
  • 本文由 发表于 2023年8月10日 20:03:12
  • 转载请务必保留本文链接:https://go.coder-hub.com/76875584.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定