How to set up a modern JavaScript development environment
· Category: JavaScript
Short answer
A modern JavaScript environment includes npm for packages, ESLint for linting, Prettier for formatting, a bundler like Vite, and a test runner like Vitest or Jest.
Steps
- Initialize the project:
bash npm init -y - Install dev tools:
bash npm install -D eslint prettier vite vitest - Configure ESLint:
javascript // eslint.config.js export default [{ rules: { "eqeqeq": "error" } }]; - Configure Prettier and add format scripts.
- Set up a bundler config for development and production.
- Add test scripts to
package.json.
Tips
- Use editor integrations to run linting and formatting on save.
- Set up git hooks with husky to enforce quality before commits.
Common issues
- Conflicting rules between ESLint and Prettier cause noise; use
eslint-config-prettierto disable conflicting rules. - Mismatched Node.js versions break tooling; use
enginesinpackage.json.