Next.js 13 - 无法解析“支持颜色”

mkk*_*kkl 6 node.js typescript next.js

我目前正在开发 Next.js 13 应用程序(使用 TypeScript)。我也是 Sendgrid npm 包。

我不断收到此警告:

Module not found: Can't resolve 'supports-color' in '.../node_modules/debug/src'

运行: npm install supports-color npm install debug@latest并不能修复它,它只是给出这个错误:

Module not found: ESM packages (supports-color) need to be imported. Use 'import' to reference the package instead
Run Code Online (Sandbox Code Playgroud)

import到处都在用 我已将其范围缩小到使用Sendgrid npm 包时发生的情况,但我不知道为什么 Sendgrid 会导致此错误。

任何想法将不胜感激。

小智 12

debug 的 GitHub 上有一个未解决的问题,在此处详细介绍了该问题。安装"supports-color": "^8.1.1"作为解决方法解决了我的错误。

npm i supports-color@8.1.1
Run Code Online (Sandbox Code Playgroud)