roundest-mon
roundest-mon copied to clipboard
Error [ERR_REQUIRE_ESM]: require() of ES Module /env/server.mjs not supported.
When trying to execute the fill-db.ts
file with the yarn ts-node ./scripts/fill-db.ts
command I get the following error:
/src/server/db/client.ts:6
var prisma: PrismaClient | undefined;
^
Error [ERR_REQUIRE_ESM]: require() of ES Module /src/env/server.mjs not supported.
Instead change the require of /src/env/server.mjs to a dynamic import() which is available in all CommonJS modules.
I tried trouble shooting with "type": "module"
in my package.json as well as other imports to make ts-node work with no luck and more errors.
Here is my package.json, I am used yarn create t3-app for this project:
{
"name": "mon",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint",
"postinstall": "prisma generate",
"ts-node": "ts-node --compiler-options \"{\\\"module\\\":\\\"commonjs\\\"}\""
},
"dependencies": {
"@next-auth/prisma-adapter": "^1.0.4",
"@prisma/client": "^4.1.1",
"@trpc/client": "^9.26.2",
"@trpc/next": "^9.26.2",
"@trpc/react": "^9.26.2",
"@trpc/server": "^9.26.2",
"next": "12.2.3",
"next-auth": "^4.10.3",
"pokenode-ts": "^1.16.0",
"react": "18.2.0",
"react-dom": "18.2.0",
"react-query": "3.39.2",
"superjson": "^1.9.1",
"zod": "^3.17.3"
},
"devDependencies": {
"@types/node": "^18.7.1",
"@types/react": "18.0.14",
"@types/react-dom": "18.0.5",
"autoprefixer": "^10.4.8",
"eslint": "8.18.0",
"eslint-config-next": "12.2.3",
"postcss": "^8.4.16",
"prisma": "^4.1.1",
"tailwindcss": "^3.1.8",
"ts-node": "^10.9.1",
"typescript": "4.7.4"
}
}
U used a require() with it. Try changing all require imports to import().