Repository navigation
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"inpackage.json). require()/module.exportsare replaced withimport/export.- Relative imports must include the
.jsextension (for example,./routes/index.js). __dirnameand__filenameare not available in ESM.app.jsnow defines them withfileURLToPath(import.meta.url).- Node.js 20 or later is now required.
What's Changed
Added
- ES Modules support across
app.js,bin/wwwandroutes/. - Tailwind CSS v4.3 with
@tailwindcss/cli^4.3.0. - Updated
index.ejswith 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
dotenvsetup.
Changed
app.jsandbin/wwwnow use ESM imports, and the app is exported withexport default app.routes/index.jsandroutes/users.jsnow useexport default router.- The Tailwind source file
public/stylesheets/tailwind.cssnow uses the Tailwind v4 layers, and compiles topublic/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
- Add
"type": "module"to yourpackage.json. - Replace
require()withimportandmodule.exportswithexport default. - Add
.jsextensions to relative imports. - Define
__dirnameif you use it:
import { fileURLToPath } from "url";
import { dirname } from "path";
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);- 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 devThe server runs at http://localhost:3000/.
Full Changelog: v1.0.0...v2.0.0