Repository navigation
Releases: mraxays/node-express-ejs-tailwindcss-starter
Releases · mraxays/node-express-ejs-tailwindcss-starter
Release list
v2.0.0 – ES Modules and Tailwind CSS v4.3
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
commonjs - Node Express Final Version
v1.0.0 – Initial Release
First release of the Node.js Express EJS Tailwind CSS Starter, a starter template for building modern web applications with Express, EJS, and Tailwind CSS. This version uses CommonJS (require / module.exports).
Features
- Express.js server setup with the latest Express version
- EJS templating for dynamic pages
- Tailwind CSS integration through
@tailwindcss/cli - Organized project structure with
routes/,views/, andpublic/ - Built-in middleware for JSON and URL-encoded request parsing, cookies, and request logging
- Error handling with a 404 handler and a custom
error.ejspage - Development workflow with Nodemon and Tailwind CSS watch mode
- Production-ready, minified CSS build
- Prettier setup with the Tailwind CSS class-sorting plugin
Included Scripts
| Command | Description |
|---|---|
npm start |
Start the application |
npm run dev |
Run the server with Nodemon and Tailwind CSS watch mode |
npm run dev:server |
Run only the development server |
npm run devcss |
Compile Tailwind CSS and watch for changes |
npm run buildcss |
Build and minify Tailwind CSS for production |
Project Structure
├── bin/www
├── public/
│ ├── images/
│ ├── javascripts/
│ └── stylesheets/tailwind.css
├── routes/
│ ├── index.js
│ └── users.js
├── views/
│ ├── index.ejs
│ └── error.ejs
├── app.js
└── package.json
Getting Started
git clone https://github.com/mraxays/node-express-ejs-tailwindcss-starter.git
cd node-express-ejs-tailwindcss-starter
npm install
npm startThe server runs at http://localhost:3000/.
Dependencies
Express, EJS, Tailwind CSS (@tailwindcss/cli), Morgan, Cookie Parser, Debug, HTTP Errors
Dev dependencies: Nodemon, Prettier, Prettier Plugin Tailwind CSS
License
Released under the MIT License.