Skip to content

Commit

Permalink
check node version in next config
Browse files Browse the repository at this point in the history
  • Loading branch information
c-ehrlich committed Oct 18, 2023
1 parent d1a8955 commit f0739a1
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
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)) {
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`);
}
}

0 comments on commit f0739a1

Please sign in to comment.