类型“{}”不可分配给类型“ReactNode”

Ján*_*nos 47 javascript reactjs next.js vercel

我收到此错误,但仅在 Vercel 中,而不是本地,为什么?

error: 'FontAwesomeIcon' cannot be used as a JSX component.
Run Code Online (Sandbox Code Playgroud)
./components/Services/ServiceContainer.tsx:25:6
12:01:54.967    Type error: 'FontAwesomeIcon' cannot be used as a JSX component.
12:01:54.967      Its element type 'ReactElement<any, any> | Component<FontAwesomeIconProps, any, any>' is not a valid JSX element.
12:01:54.968        Type 'Component<FontAwesomeIconProps, any, any>' is not assignable to type 'Element | ElementClass'.
12:01:54.968          Type 'Component<FontAwesomeIconProps, any, any>' is not assignable to type 'ElementClass'.
12:01:54.968            The types returned by 'render()' are incompatible between these types.
12:01:54.968              Type 'React.ReactNode' is not assignable to type 'import("/vercel/path0/node_modules/@types/styled-jsx/node_modules/@types/react/index").ReactNode'.
12:01:54.968                Type '{}' is not assignable to type 'ReactNode'.
Run Code Online (Sandbox Code Playgroud)
error: 'FontAwesomeIcon' cannot be used as a JSX component.
Run Code Online (Sandbox Code Playgroud)
./components/Services/ServiceContainer.tsx:25:6
12:01:54.967    Type error: 'FontAwesomeIcon' cannot be used as a JSX component.
12:01:54.967      Its element type 'ReactElement<any, any> | Component<FontAwesomeIconProps, any, any>' is not a valid JSX element.
12:01:54.968        Type 'Component<FontAwesomeIconProps, any, any>' is not assignable to type 'Element | ElementClass'.
12:01:54.968          Type 'Component<FontAwesomeIconProps, any, any>' is not assignable to type 'ElementClass'.
12:01:54.968            The types returned by 'render()' are incompatible between these types.
12:01:54.968              Type 'React.ReactNode' is not assignable to type 'import("/vercel/path0/node_modules/@types/styled-jsx/node_modules/@types/react/index").ReactNode'.
12:01:54.968                Type '{}' is not assignable to type 'ReactNode'.
Run Code Online (Sandbox Code Playgroud)

小智 28

上周,我们在构建服务器上开始遇到此问题,但没有做出重大更改,并且尚未设法找到解决方案,但其他团队遇到与此错误相关的突然问题时已经产生了一些问题。

在 React GitHub 页面上查看此问题,在 redwoodjs GitHub 页面上查看此问题

更新

Yevhen Rybak 的答案对我们有用。

我还必须添加preinstall scriptSahil Patel 的答案

  • 请不要仅发布链接,还要发布链接中的相关信息,因为链接将来可能会更改或损坏 (76认同)