What you will learn
- Install packages and run scripts with npm and package.json
- Use a formatter and linter in VS Code to keep code consistent
- Keep secrets in environment variables and document how to run a project
Most modern web projects use Node.js and its package manager, npm. A package.json file lists the project's dependencies and its scripts. npm install downloads every dependency into node_modules, and the package-lock.json file records exact versions so everyone gets the same setup. Scripts are shortcuts for common tasks, so npm run dev might start a local development server and npm run build might produce the final site.
Formatters and linters keep code tidy. Prettier is a widely used formatter that rewrites code to a consistent style, which ends arguments over spacing and quotes. ESLint is a linter that warns about likely mistakes, such as unused variables. Both integrate with VS Code, and many developers set the editor to format a file every time it is saved.
Keep passwords and API keys out of your code. Store them in environment variables, often in a .env file that is listed in .gitignore, and read them in your code at runtime. Write down what the project needs in the README, such as how to install it and which variables to set. Clear setup steps make it easy to return to a project months later.


