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

时间:2021-08-01 23:33:38

标签: javascript reactjs next.js

我是 next 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)

下面是Index.js文件

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,
    },
  };
}

下面是下一个。配置文件

module.exports = {
  // reactStrictMode: true,
  webpack5: true,
  images: {
    domains: [
      "http://localhost:3000/",
      "m.media-amazon.com",
      "links.papareact.com",
      "platform-lookaside.fbsbx.com",
      "firebasestorage.googleapis.com",
      "facebookbrand.com",
      "pbs.twimg.com",
    ],
  },
};

Git 存储库 - Git repository

0 个答案:

没有答案