A minimal Node.js starter that uses ECMAScript modules, path aliases, linting, and formatting so you can begin new experiments quickly without rebuilding the same setup.
- Node.js ESM configuration with
"type": "module"for modern import/export syntax. - Path aliasing via
package.json#importsso files insidesrccan import using#src/.... - Automated code style with Prettier and XO, plus AVA ready for unit testing.
- Husky pre-commit hook running lint-staged to auto-fix staged files before every commit.
- Simple example module (
greet.js) and entry point (src/index.js) to verify the tooling.
- Node.js
>=18 - npm (bundled with Node.js)
npm installnpm start– Runs the example application withnodemon srcand prints a greeting.npm test– Runs the AVA test suite.npx xo– Lints the project using XO.npx prettier --write .– Formats the codebase using Prettier.
src/
index.js # Entry point that imports using the #src alias
modules/
greet.js # Sample module demonstrating modular structure
The alias defined in package.json lets you write imports such as:
import greet from "#src/modules/greet.js";Adjust the mapping in package.json#imports if you reorganize the src directory.
- Implement changes in
src/. - Run
npm startto spin up thenodemonwatcher while developing. - Run
npx xoto catch lint issues and usenpm testas you expand the AVA suite. - Use Prettier for consistent formatting; Husky + lint-staged will also auto-format staged files on commit.
This project is released under the MIT License.