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
1 Answer
Reset to default 7I ran into a similar error message. To fix:
I deleted node_modules
and npm installed again and things started working again.