最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - _chalk.default.constructor is not a constructor in next.js - Stack Overflow

programmeradmin1浏览0评论

I am new to next Next.js. I am getting error,I tried to change next.config for webpack ,still error.

After adding getServerSideProps in Index.jsx error start to appear.

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)

Below is Index.js file

import Head from "next/head";
// import 'tailwindcss/tailwind.css'
import React from "react";
import Header from "../ponents/Header";
import Login from "../ponents/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,
    },
  };
}

I am new to next Next.js. I am getting error,I tried to change next.config for webpack ,still error.

After adding getServerSideProps in Index.jsx error start to appear.

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)

Below is Index.js file

import Head from "next/head";
// import 'tailwindcss/tailwind.css'
import React from "react";
import Header from "../ponents/Header";
import Login from "../ponents/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,
    },
  };
}

below is next. config.js

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

Git repo- Git repository

Share Improve this question asked Aug 1, 2021 at 23:33 Ravi ShankarRavi Shankar 1451 gold badge4 silver badges14 bronze badges 2
  • Where does getSession e from? – juliomalves Commented Aug 2, 2021 at 11:56
  • @juliomalves its probably next-auth :) – deadcoder0904 Commented Oct 26, 2021 at 13:15
Add a ment  | 

1 Answer 1

Reset to default 7

I ran into a similar error message. To fix:

I deleted node_modules and npm installed again and things started working again.

发布评论

评论列表(0)

  1. 暂无评论