Skip to content

v2.0.0 – ES Modules and Tailwind CSS v4.3

Latest

Choose a tag to compare

@mraxays mraxays released this 11 Oct 13:17

v2.0.0 – ES Modules and Tailwind CSS v4.3

This release moves the starter from CommonJS to ES Modules (ESM), updates Tailwind CSS to v4.3, and refreshes the homepage and documentation.

Looking for the CommonJS version? Use v1.0.0.

⚠️ Breaking Changes

  • The project now uses ES Modules ("type": "module" in package.json).
  • require() / module.exports are replaced with import / export.
  • Relative imports must include the .js extension (for example, ./routes/index.js).
  • __dirname and __filename are not available in ESM. app.js now defines them with fileURLToPath(import.meta.url).
  • Node.js 20 or later is now required.

What's Changed

Added

  • ES Modules support across app.js, bin/www and routes/.
  • Tailwind CSS v4.3 with @tailwindcss/cli ^4.3.0.
  • Updated index.ejs with an improved HTML structure and Tailwind CSS classes.
  • README badges for license, latest release and views.
  • Documentation for how the project works, changing the port, and the optional dotenv setup.

Changed

  • app.js and bin/www now use ESM imports, and the app is exported with export default app.
  • routes/index.js and routes/users.js now use export default router.
  • The Tailwind source file public/stylesheets/tailwind.css now uses the Tailwind v4 layers, and compiles to public/stylesheets/styles.css.
  • README rewritten to match the ESM setup, current dependencies and project structure.

Fixed

  • ReferenceError: __dirname is not defined in ES module scope.

Upgrading from v1.x

  1. Add "type": "module" to your package.json.
  2. Replace require() with import and module.exports with export default.
  3. Add .js extensions to relative imports.
  4. Define __dirname if you use it:
   import { fileURLToPath } from "url";
   import { dirname } from "path";

   const __filename = fileURLToPath(import.meta.url);
   const __dirname = dirname(__filename);
  1. Update Tailwind to v4 and rebuild your CSS with npm run buildcss.

Getting Started

git clone git@github.com:mraxays/node-express-ejs-tailwindcss-starter.git
cd node-express-ejs-tailwindcss-starter
npm install
npm run dev

The server runs at http://localhost:3000/.

Full Changelog: v1.0.0...v2.0.0