【问题标题】:I am getting errors when deploying to Vercel. Can anyone help me with the my issues below?部署到 Vercel 时出现错误。谁能帮我解决下面的问题?
【发布时间】:2022-01-19 07:45:51
【问题描述】:

克隆 github.com/gmcnally78/-Final-Data-Driven-FullStack-App2(分支:main,提交:e1d0133)

克隆完成:643.936ms

正在分析源代码...

正在安装构建运行时...

已安装构建运行时:2.278s

正在查找构建缓存...

未找到构建缓存

安装依赖...

纱线安装 v1.22.17

[1/4] 解决包...

[2/4] 正在获取包...

[3/4] 链接依赖...

警告 " > @chakra-ui/icons@1.1.1" 具有未满足的对等依赖关系 "@chakra-ui/system@>=1.0.0"。

警告“@chakra-ui/icons > @chakra-ui/icon@1.2.1”具有未满足的对等依赖关系“@chakra-ui/system@>=1.0.0”。

警告“@emotion/styled > @emotion/babel-plugin@11.7.1”有未满足的对等依赖“@babel/core@^7.0.0”。

警告“@emotion/styled > @emotion/babel-plugin > @babel/plugin-syntax-jsx@7.16.5”未满足对等依赖“@babel/core@^7.0.0-0”。

警告 "next > styled-jsx > @babel/plugin-syntax-jsx@7.14.5" 具有未满足的对等依赖关系 "@babel/core@^7.0.0-0"。

警告“ > eslint-config-next@11.1.0”具有未满足的对等依赖关系“eslint@^7.23.0”。

警告“eslint-config-next > @typescript-eslint/parser@4.29.0”未满足对等依赖“eslint@^5.0.0 || ^6.0.0 || ^7.0.0”。

警告“eslint-config-next > eslint-import-resolver-typescript@2.4.0”未满足对等依赖“eslint@*”。

警告“eslint-config-next > eslint-plugin-import@2.23.4”具有未满足的对等依赖关系“eslint@^2 || ^3 || ^4 || ^5 || ^6 || ^7.2 .0"。

警告“eslint-config-next > eslint-plugin-jsx-a11y@6.4.1”未满足对等依赖“eslint@^3 || ^4 || ^5 || ^6 || ^7”。

警告“eslint-config-next > eslint-plugin-react@7.24.0”未满足对等依赖“eslint@^3 || ^4 || ^5 || ^6 || ^7”。

警告“eslint-config-next > eslint-plugin-react-hooks@4.2.0”具有未满足的对等依赖关系“eslint@^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0 .0 || ^7.0.0".

[4/4] 构建新包...

成功保存锁文件。

在 47.72 秒内完成。

检测到 Next.js 版本:11.1.3

运行“yarn run build”

yarn run v1.22.17

$ 下一次构建

信息 - 使用 webpack 5。原因:默认启用 https://nextjs.org/docs/messages/webpack5

注意:Next.js 现在收集有关使用情况的完全匿名遥测数据。

此信息用于塑造 Next.js 的路线图并确定功能的优先级。

您可以通过访问以下 URL 了解更多信息,包括如果您不想参与此匿名计划,如何选择退出:

https://nextjs.org/telemetry

浏览器列表:caniuse-lite 已过时。请运行:

npx browserslist@latest --update-db

为什么你应该经常这样做:

https://github.com/browserslist/browserslist#browsers-data-updating

info - 检查类型的有效性...

警告 - 未检测到 ESLint 配置。运行下一个 lint 开始设置

info - 创建优化的生产版本...

浏览器列表:caniuse-lite 已过时。请运行:

npx browserslist@latest --update-db

为什么你应该经常这样做:

https://github.com/browserslist/browserslist#browsers-data-updating

编译失败。

ModuleNotFoundError: Module not found: Error: Can't resolve '../components/Header' in '/vercel/path0/pages/todos'

发生构建错误

错误:> 由于 webpack 错误,构建失败

at /vercel/path0/node_modules/next/dist/build/index.js:397:19

at async Span.traceAsyncFn

(/vercel/path0/node_modules/next/dist/telemetry/trace/trace.js:60:20) 在 async Object.build [默认]

(/vercel/path0/node_modules/next/dist/build/index.js:77:25)

error 命令失败,退出代码为 1。

info 请访问https://yarnpkg.com/en/docs/cli/run 获取有关此命令的文档。

错误:命令“yarn run build”以 1 退出

信息 - 从 /Users/gregmcnally/Downloads/CS55.13-todo-app-week-8-main/.env.local 加载的环境

信息 - 使用 webpack 5。原因:默认启用

https://nextjs.org/docs/messages/webpack5

编译失败。

./pages/ssr-no-token.tsx:62:51

类型错误:类型参数 'IncomingMessage & { cookies: NextApiRequestCookies; }' 是 不能分配给“null |”类型的参数未定义'。

输入'IncomingMessage & { cookies: NextApiRequestCookies; }' 不能分配给类型 'null'。

VS 代码 60 | //withAuthUserTokenSSR。 61 | const token = await AuthUser.getIdToken()

62 | const 端点 = getAbsoluteURL('/api/example', req) | ^ 63 |常量响应=等待获取(端点,{ 64 |方法:'GET', 65 |标题:{ info - 检查类型 .npm ERR 的有效性!代码生命周期 npm 错误!错误号 1 npm 错误! todo-app-week08@0.1.0 构建:next build npm 错误!退出状态 1 npm 错误! npm 错误!在 todo-app-week08@0.1.0 构建脚本中失败。 npm 错误!这可能不是 npm 的问题。上面可能还有额外的日志输出。

npm 错误!可以在以下位置找到此运行的完整日志: npm 错误! /Users/gregmcnally/.npm/_logs/2021-12-16T06_44_01_675Z-debug.log gregmcnally@Gregs-MBP CS55.13-todo-app-week-8-main %

【问题讨论】:

  • 欢迎来到 StackOverflow!请添加您面临的具体错误,无需添加整个故事。还请说明您为解决问题所做的努力。谢谢!
  • 请编辑问题以将其限制为具有足够详细信息的特定问题,以确定适当的答案。

标签: node.js reactjs npm webpack environment-variables


【解决方案1】:

首先我建议你尝试运行:

yarn buildnpm run build 本地,因为在尝试部署到 Vercel 之前,您将能够发现很多这些错误。

有几个错误:

ModuleNotFoundError: Module not found: Error: Can't resolve '../components/Header' in '/vercel/path0/pages/todos'

告诉我们您的项目无法解析待办事项页面中“标题”组件的导入。查看您项目中的该页面并确保您使用的是正确的导入路径。

其次,ssr-no-token.tsx: 中存在类型错误,因此类型验证导致构建失败。

 Type error: Argument of type 'IncomingMessage & { cookies: NextApiRequestCookies; }' is 
not assignable to parameter of type 'null | undefined'.

如果我们查看错误消息,我们可以看到您需要添加检查以确保 cookie 不是 nullundefined(并且是 NextApiRequestCookies 类型)

【讨论】:

  • 感谢您的回答。我发现这些错误是因为环境变量没有正确输入。在我的一个变量中,我有一个值的键,我从 .env.local 文件中复制并粘贴了该值。密钥的开头和结尾都有单引号,所以我删除了这些,我能够部署我的应用程序。谢谢,再次回复
猜你喜欢
  • 2023-02-05
  • 1970-01-01
  • 2022-01-25
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2023-03-30
  • 1970-01-01
相关资源
最近更新 更多