51工具盒子

依楼听风雨
笑看云卷云舒,淡观潮起潮落

Command “npm run build” exited with 126 Vercel.

英文:

Command <<npm run build>> exited with 126 Vercel

问题 {#heading}

我尝试使用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 &quot;vercel build&quot;
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 &quot;npm run build&quot;
`sh: /vercel/path0/node_modules/.bin/webpack: Permission denied
Error: Command &quot;npm run build&quot; 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}

得分: 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.


赞(1)
未经允许不得转载:工具盒子 » Command “npm run build” exited with 126 Vercel.