Skip to content
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

feat: check node version in next config #1608

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/proud-islands-move.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"create-t3-app": minor
---

check node version in next config
13 changes: 13 additions & 0 deletions cli/template/base/next.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
*/
await import("./src/env.mjs");

checkNodeVersion();

/** @type {import("next").NextConfig} */
const config = {
reactStrictMode: true,
Expand All @@ -20,3 +22,14 @@ const config = {
};

export default config;

function checkNodeVersion() {
const nodeVersion = process.versions.node;
const [major, minor] = nodeVersion.split(".").map((n) => parseInt(n));
if (!major || !minor) {
throw new Error(`Unable to parse Node version: ${nodeVersion}`);
}
if (major < 18 || (major === 18 && minor < 6) || (major === 19 && minor < 7)) {
Copy link

@sscotth sscotth Oct 18, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this be major === 18 && minor < 16?

Same on cli/template/extras/config/next-config-appdir.mjs

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

16 is EOL

Copy link

@sscotth sscotth Oct 18, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you misread minor, his check is "<18.6" not "<18.16".

Since you mentioned it, since v19 is also EOL as of 2023-06-01, should we remove v19 all together and check for v20+?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, thanks :)

throw new Error(`You are running an outdated Node version. Please use at least 18.16, 19.7, or 20.0`);
}
}
13 changes: 13 additions & 0 deletions cli/template/extras/config/next-config-appdir.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,20 @@
*/
await import("./src/env.mjs");

checkNodeVersion();

/** @type {import("next").NextConfig} */
const config = {};

export default config;

function checkNodeVersion() {
const nodeVersion = process.versions.node;
const [major, minor] = nodeVersion.split(".").map((n) => parseInt(n));
if (!major || !minor) {
throw new Error(`Unable to parse Node version: ${nodeVersion}`);
}
if (major < 18 || (major === 18 && minor < 6) || (major === 19 && minor < 7)) {
throw new Error(`You are running an outdated Node version. Please use at least 18.16, 19.7, or 20.0`);
}
}
Loading