嘿,伙计们,我想部署我的项目。我通过我的终端运行Vercel,它没有出现错误,但是当运行vercel部署时,我一直得到Build Failed Command "npm run build" exited with 1
任何建议或修正都会得到极大的认可!我看到它说我需要一个projectId,但是我的.env.local包含我的id
NEXT_PUBLIC_SANITY_DATASET=production
NEXT_PUBLIC_SANITY_PROJECT_ID=8a64h111
NEXT_PUBLIC_BASE_URL=http://localhost:3000/````
I'm really stumped here.
```23:27:55.917 | Error: Configuration must contain `projectId`23:27:55.917在(/vercel/path0/node_modules/@sanity/client/lib/config.js:42:11) exports.initConfig
23:27:55.918在(/vercel/path0/node_modules/@sanity/client/lib/sanityClient.js:89:25) SanityClient.config
23时27分55.918分在新的(/vercel/path0/node_modules/@sanity/client/lib/sanityClient.js:53:8) SanityClient
23:27:55.918在(/vercel/path0/node_modules/@sanity/client/lib/sanityClient.js:50:12) SanityClient
23:27:55.918在(/vercel/path0/node_modules/next-sanity/dist/next-sanity.cjs.production.min.js:1:1023) exports.createClient
23:27:55.918在Object.5149 (/vercel/path0/.next/server/pages/index.js:1055:75)上
23:27:55.919在webpack_require (/vercel/path0/.next/server/webpack-runtime.js:25:42)
23:27:55.919在/vercel/path0/.next/server/pages/index.js:20:65
23:27:55.919在Function.webpack_require.a (/vercel/path0/.next/server/webpack-runtime.js:89:13)
23:27:55.919在Object.2265 (/vercel/path0/.next/server/pages/index.js:11:21)
23:27:55.920
23:27:55.920 >生成错误
23:27:55.922 \x{e76f}错误:未能为/收集页数据
23:27:55.922在/vercel/path0/node_modules/next/dist/build/utils.js:916:15 {
23:27:55.922 \x{e76f}类型:“错误”
23:27:55.923
23:27:55.978 \x\x{e76f}错误:命令"npm运行构建“命令退出1‘
发布于 2022-10-03 04:22:29
`23:27:55.917 \x{e76f}错误:配置必须包含
projectId
看起来您没有在Varcel上添加环境变量"projectId“。这是怎么做的。。如果您添加了它,检查是否有错误在那里。
发布于 2022-10-03 04:32:34
除了堆栈跟踪之外,您还需要提供更多信息,但假设所有库都正常工作.
默认情况下,大多数库都不会从.env.local或process.env读取。首先使用另一个库(如dotenv流)将.env.local加载到process.env中,然后将配置(通常是对象)传递给库的构造函数。
pages/index.js的第20行第65列(假设您不是从类型记录编译)可能如下所示:createClient(),您希望它看起来如下:createClient({projectId: process.env.projectId})
https://stackoverflow.com/questions/73931018
复制相似问题