Skip to content

Add Node.js version gate and fix ESM path resolution#17

Merged
ChangeHow merged 2 commits intodevfrom
copilot/sub-pr-10-0c7033ee-95fb-4e1c-ae0b-b976accdefbc
Mar 11, 2026
Merged

Add Node.js version gate and fix ESM path resolution#17
ChangeHow merged 2 commits intodevfrom
copilot/sub-pr-10-0c7033ee-95fb-4e1c-ae0b-b976accdefbc

Conversation

Copy link

Copilot AI commented Mar 11, 2026

cli.js uses top-level await and native ESM, requiring Node ≥ 18. There was no runtime guard against older versions, and src/utils/fs.js had a silent bug (import.meta.dirname is non-standard and returns undefined).

Changes

  • src/utils/node-version.js — new utility; checks process.version against the Node 18 minimum and exits with a clear upgrade message if not met
  • src/cli.js — calls checkNodeVersion() before any setup logic
  • package.json — adds "engines": { "node": ">=18.0.0" } for tooling-level enforcement
  • src/utils/fs.js — fixes projectRoot() to use dirname(fileURLToPath(import.meta.url)) instead of import.meta.dirname
// src/utils/node-version.js
export function checkNodeVersion() {
  const major = parseInt(process.version.replace(/^v/, "").split(".")[0], 10);
  if (major < 18) {
    console.error(
      `suitup requires Node.js 18 or later for native ESM support.\n` +
      `You are running Node.js ${process.version}.\n` +
      `Please upgrade: https://nodejs.org/en/download`
    );
    process.exit(1);
  }
}

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Co-authored-by: ChangeHow <23733347+ChangeHow@users.noreply.github.com>
Copilot AI changed the title [WIP] Add Node version checker and ESM support validation Add Node.js version gate and fix ESM path resolution Mar 11, 2026
@ChangeHow ChangeHow marked this pull request as ready for review March 11, 2026 02:59
@ChangeHow ChangeHow merged commit 98a6935 into dev Mar 11, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants