_chalk.default.constructor 不是 next.js 中的构造函数

Rav*_*kar 0 javascript reactjs next.js

我是下一个 Next.js 的新手。我收到错误,我尝试更改 webpack 的 next.config ,仍然错误。

在 Index.jsx 中添加getServerSideProps后,开始出现错误。

TypeError: _chalk.default.constructor is not a constructor
at Object.<anonymous> (C:\Users\jai shankar\Desktop\RSS\React\Next\fbclone-yt\node_modules\next\dist\build\webpack\plugins\wellknown-errors-plugin\parseBabel.js:1:277)

at Object.<anonymous> (C:\Users\jai shankar\Desktop\RSS\React\Next\fbclone-yt\node_modules\next\dist\build\webpack\plugins\wellknown-errors-plugin\webpackModuleError.js:1:174)
Run Code Online (Sandbox Code Playgroud)

下面是Index.js文件

TypeError: _chalk.default.constructor is not a constructor
at Object.<anonymous> (C:\Users\jai shankar\Desktop\RSS\React\Next\fbclone-yt\node_modules\next\dist\build\webpack\plugins\wellknown-errors-plugin\parseBabel.js:1:277)

at Object.<anonymous> (C:\Users\jai shankar\Desktop\RSS\React\Next\fbclone-yt\node_modules\next\dist\build\webpack\plugins\wellknown-errors-plugin\webpackModuleError.js:1:174)
Run Code Online (Sandbox Code Playgroud)

下面是下一个。配置文件

import Head from "next/head";
// import 'tailwindcss/tailwind.css'
import React from "react";
import Header from "../components/Header";
import Login from "../components/Login";

export default function Home({ session }) {
  if (!session) return <Login />;

  return (
    <div>
      <Head>
        <title>Facebook clone</title>
        <meta name="description" content="Generated by create next app" />
        <link rel="icon" href="/favicon.ico" />
      </Head>

      {/* Header */}
      <Header />
      <main>
        {/* sidebar */}

        {/* fees */}

        {/* Widget */}
      </main>
    </div>
  );
}

export async function getServerSideProps(context) {
  const session = await getSession(context);
  return {
    props: {
      session,
    },
  };
}
Run Code Online (Sandbox Code Playgroud)

Git repo- Git 存储库

Eli*_*ock 7

我遇到了类似的错误消息。修理:

我删除node_modules并再次安装 npm,一切又开始工作了。