javascript 错误提示:不能从服务器组件点入客户端模块,您只能将导入的名称通过

u3r8eeie  于 2023-10-14  发布在  Java
关注(0)|答案(1)|浏览(163)

我的NextJS应用程序如下:
app/page.js

'use client';
import React from 'react';

export default function Home() {
   return (<div>Testing</div>);
}

app/layout.js

export const metadata = {
  title: 'Next.js',
  description: 'Generated by Next.js',
}
 
export default function RootLayout({ children }) {
 return (
    <html lang="en">
      <body>{children}</body>
    </html>
  )
}

当我运行

next dev

我得到以下错误:

error - node_modules/next/dist/build/webpack/loaders/next-flight-loader/module-proxy.js (56:14) @ Object.get
error - Error: Cannot access default.then on the server. You cannot dot into a client module from a server component. You can only pass the imported name through.
    at async Promise.all (index 0)
null
error - node_modules/next/dist/build/webpack/loaders/next-flight-loader/module-proxy.js (56:14) @ Object.get
error - Error: Cannot access default.then on the server. You cannot dot into a client module from a server component. You can only pass the imported name through.
    at async Promise.all (index 0)

我找不到任何关于违约的参考资料。有没有办法缩小这个错误?我还没有能够找到这个错误在网络搜索,所以任何关于错误的信息将不胜感激。

bxjv4tth

bxjv4tth1#

如果您使用的是旧版本,则可以使用13.4.19latest升级next.js版本。Next.js Official docs to upgrade your application

相关问题