Skip to main content

Creating a project

Let’s set up a proper JavaScript project from scratch. This is the same process you’ll follow for every new project.
1

Create a folder and initialize npm

The -y flag accepts all defaults. This creates a package.json file in your folder.
2

Create your entry file

Create an index.js file:
index.js
3

Add a start script

Open package.json and update the scripts section:
package.json
Now you can run your project with:

Project structure

A typical JavaScript project looks like this:
For the practice exercises in this course, you don’t need the src/ folder — a flat structure with .js files at the root is fine. You’ll use a more structured layout when you get to React.

Setting up .gitignore

Create a .gitignore file in your project root:
.gitignore
The most important line is node_modules/. This folder can contain thousands of files and hundreds of megabytes. Everyone who clones your project runs npm install to generate their own copy.
Always add .env to .gitignore. Environment files often contain API keys, database passwords, and other secrets that should never be committed to git.

.env files

You’ll use .env files later in the course to store configuration like API URLs. Here’s a preview:
.env
For now, just know that:
  1. .env files store configuration as key-value pairs
  2. They should never be committed to git
  3. Create a .env.example file (without real values) to show other developers what variables they need
Create a .env.example file with placeholder values so other developers know what environment variables your project expects. Commit this file to git.

Verify your setup

At this point, you should have:
  • Node.js installed (node -v shows a version)
  • npm available (npm -v shows a version)
  • VS Code with ESLint and Prettier extensions
  • A practice folder where you can create and run .js files
If all of that checks out, you’re ready to learn JavaScript.

What’s next?

Your development environment is set up. Time to learn the language. Let’s start with how JavaScript works and how it compares to Python.

JavaScript basics

What JavaScript is, how it compares to Python, and essential syntax