Skip to main content

使用 vercel/pkg 解决包错误

问题

¥Problem

如果你使用 Vercel/封装 来打包 Node.js 项目,那么你可能会遇到如下 ENOENT 错误:

¥If you use vercel/pkg to package your Node.js project, then you might encounter an ENOENT error like the following:

spawn /snapshot/enoent-problem/node_modules/.prisma/client/query-engine-debian-openssl-1.1.x ENOENT

解决方案

¥Solution

为了避免此错误,请将 Prisma 查询引擎二进制路径添加到 package.json 文件的 pkg/assets 部分,如下所示:

¥To avoid this error, add your Prisma query engine binary path to the pkg/assets section of your package.json file, as follows:

package.json
{
"pkg": {
"assets": ["node_modules/.prisma/client/*.node"]
}
}

进一步讨论请参见 这个 Github 问题

¥See this Github issue for further discussion.