Deploy netlify failed

I made a new project with create-t3-app yesterday. But today after I deployed the project to netlify (github repo) via netlify dashboard, and when the deployment was done. I tried to access the page but I got an error:
ReferenceError: module is not defined in ES module scope
This file is being treated as an ES module because it has a '.js' file extension and '/var/task/package.json' contains "type": "module". To treat it as a CommonJS script, rename it to use the '.cjs' file extension.
at file:///var/task/___netlify-handler.js:1:1
at ModuleJob.run (node:internal/modules/esm/module_job:194:25)
ReferenceError: module is not defined in ES module scope
This file is being treated as an ES module because it has a '.js' file extension and '/var/task/package.json' contains "type": "module". To treat it as a CommonJS script, rename it to use the '.cjs' file extension.
at file:///var/task/___netlify-handler.js:1:1
at ModuleJob.run (node:internal/modules/esm/module_job:194:25)
Here is a part of package.json
{
"name": "create-t3-app",
"version": "0.1.0",
"private": true,
"type": "module",
"scripts": {
"build": "next build",
"schema:format": "prisma format",
"db:push": "prisma db push",
"db:studio": "prisma studio",
"dev": "next dev",
"postinstall": "prisma generate",
"lint": "next lint",
"format": "prettier --log-level warn --write \"**/*.{jsx,js,ts,tsx}\"",
"start": "next start"
},
"dependencies": {...},
"devDependencies": {...},
"ct3aMetadata": {
"initVersion": "7.25.2"
},
"packageManager": "yarn@1.22.10"
}
{
"name": "create-t3-app",
"version": "0.1.0",
"private": true,
"type": "module",
"scripts": {
"build": "next build",
"schema:format": "prisma format",
"db:push": "prisma db push",
"db:studio": "prisma studio",
"dev": "next dev",
"postinstall": "prisma generate",
"lint": "next lint",
"format": "prettier --log-level warn --write \"**/*.{jsx,js,ts,tsx}\"",
"start": "next start"
},
"dependencies": {...},
"devDependencies": {...},
"ct3aMetadata": {
"initVersion": "7.25.2"
},
"packageManager": "yarn@1.22.10"
}
Can you guys help me to resolve this error? Thanks!
2 Replies
kimprosh
kimprosh5mo ago
I try to deploy on vercel and it is success
basedgoat
basedgoat5mo ago
I'm also running into this error - I'm also getting that the error is from Netlify's own code. Do you by any chance know why we're getting this error? Curiously, locally it runs perfectly (which makes sense, because it is Netlify's own code that is breaking the EJS rules)