-
-
Notifications
You must be signed in to change notification settings - Fork 86
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error in new Next.js 15 version #276
Comments
Now i tried changing the
|
According to https://nextjs.org/docs/app/building-your-application/configuring/typescript#type-checking-nextconfigts , |
So what should I do?? Change it to a .js?? |
I tried it changing it to a next.config.mjs and changing the env.ts to env.js and again the error:
|
I think until it supports ESM, you'll need to continue using jiti https://env.t3.gg/docs/nextjs#validate-schema-on-build-(recommended) |
I solved it temporaly by using this code: import { NextConfig } from "next";
import { createJiti } from "jiti";
import { fileURLToPath } from "url";
const jiti = createJiti(fileURLToPath(import.meta.url));
async function loadEnv() {
await jiti.import("./src/env.js");
}
loadEnv().catch((e) => {
console.error(e);
process.exit(1);
});
const nextConfig: NextConfig = {};
export default withSentryConfig(nextConfig, {
org: "my-org",
project: "project",
silent: !process.env.CI,
widenClientFileUpload: true,
reactComponentAnnotation: {
enabled: true,
},
}); which also works with sentry |
Can you give us more information about how you fix it? |
I just used jiti anc created an async function to be executable. You must use Also, make sure you have the I have a repo https://github.com/TheCukitoDev/old-starter where you can see it |
It seems that maybe 15.0.2 or 15.0.3 fixed next.config.ts to be able to use ESM. I've successfully dropped jiti from my project. First, rename -// @ts-check
-import createJiti from "jiti";
-import { fileURLToPath } from "node:url";
-const jiti = createJiti(fileURLToPath(import.meta.url));
-
-// Import env here to validate during build. Using jiti we can import .ts files :)
-await jiti("./src/env");
-
-/**
- * @type {import("next").NextConfig}
- **/
+import "~/env"; Also, make sure you are using esm exports instead of module.export. Then you can drop jiti from your package.json Also, see #282 |
I've got an error when I upgraded to Next 15. This is the
next.config.ts
file I used:And i just received this error:
I don't know what to do...
The text was updated successfully, but these errors were encountered: