next.js vercel Build中的部署出错失败命令“npm run build”退出,返回% 1

au9on6nz  于 2023-05-17  发布在  其他
关注(0)|答案(1)|浏览(385)

我正在使用Firebase身份验证和数据库构建Next.js项目。它在本地运行良好,但在任何托管网站得到错误信息

[02:57:52.702] Running build in San Francisco, USA (West) – sfo1
[02:57:52.755] Cloning github.com/Sumukha87/Post-it (Branch: main, Commit: 96c0ce0)
[02:57:52.763] Skipping build cache, deployment was triggered without cache.
[02:57:53.382] Cloning completed: 626.489ms
[02:57:53.577] Running "vercel build"
[02:57:54.147] Vercel CLI 29.0.3
[02:57:54.473] Installing dependencies...
[02:58:08.594] 
[02:58:08.594] added 201 packages in 14s
[02:58:08.594] 
[02:58:08.594] 23 packages are looking for funding
[02:58:08.594]   run `npm fund` for details
[02:58:08.615] Detected Next.js version: 13.3.2
[02:58:08.618] Detected `package-lock.json` generated by npm 7+...
[02:58:08.619] Running "npm run build"
[02:58:09.016] 
[02:58:09.016] > creative-think1@0.1.0 build
[02:58:09.017] > next build
[02:58:09.017] 
[02:58:09.590] Attention: Next.js now collects completely anonymous telemetry regarding usage.
[02:58:09.591] This information is used to shape Next.js' roadmap and prioritize features.
[02:58:09.591] You can learn more, including how to opt-out if you'd not like to participate in this anonymous program, by visiting the following URL:
[02:58:09.591] https://nextjs.org/telemetry
[02:58:09.591] 
[02:58:09.751] info  - Linting and checking validity of types...
[02:58:09.924] info  - Creating an optimized production build...
[02:58:20.985] info  - Compiled successfully
[02:58:20.990] info  - Collecting page data...
[02:58:21.879] unhandledRejection Error [FirebaseError]: Firebase: Error (auth/invalid-api-key).
[02:58:21.879]     at createErrorInternal (file:///vercel/path0/node_modules/@firebase/auth/dist/node-esm/totp-035c6eef.js:490:40)
[02:58:21.880]     at _assert (file:///vercel/path0/node_modules/@firebase/auth/dist/node-esm/totp-035c6eef.js:494:15)
[02:58:21.880]     at Component.instanceFactory (file:///vercel/path0/node_modules/@firebase/auth/dist/node-esm/totp-035c6eef.js:6506:9)
[02:58:21.881]     at Provider.getOrInitializeService (file:///vercel/path0/node_modules/@firebase/component/dist/esm/index.esm2017.js:290:39)
[02:58:21.882]     at Provider.initialize (file:///vercel/path0/node_modules/@firebase/component/dist/esm/index.esm2017.js:234:31)
[02:58:21.882]     at initializeAuth (file:///vercel/path0/node_modules/@firebase/auth/dist/node-esm/totp-035c6eef.js:2943:27)
[02:58:21.882]     at getAuth (file:///vercel/path0/node_modules/@firebase/auth/dist/node-esm/totp-035c6eef.js:6571:18)
[02:58:21.883]     at /vercel/path0/.next/server/chunks/609.js:38:68 {
[02:58:21.883]   type: 'FirebaseError',
[02:58:21.883]   code: 'auth/invalid-api-key',
[02:58:21.884]   customData: { appName: '[DEFAULT]' }
[02:58:21.892] }
[02:58:21.959] Error: Command "npm run build" exited with 1
[02:58:22.316] Deployment completed
[02:58:22.275] BUILD_UTILS_SPAWN_1: Command "npm run build" exited with 1

我尝试将build命令更改为CI= npm build,但仍然不起作用。

1aaf6o9v

1aaf6o9v1#

看起来有一个firebase错误,导致了构建的问题。“错误(auth/invalid-api-key)。"。找到您正在执行此操作的位置(理想情况下使用ENV变量),并确保正确填充这些值。我猜您只需要在部署站点上添加环境变量。

相关问题