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

mkdir my-js-project
cd my-js-project
npm init -y
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
const APP_NAME = "My JS Project";

console.log(`${APP_NAME} is running!`);
3

Add a start script

Open package.json and update the scripts section:
package.json
{
  "name": "my-js-project",
  "version": "1.0.0",
  "scripts": {
    "start": "node index.js"
  }
}
Now you can run your project with:
npm start
# My JS Project is running!

Project structure

A typical JavaScript project looks like this:
my-js-project/
├── node_modules/     # Installed packages (don't touch)
├── src/              # Your source code
│   └── index.js
├── package.json      # Project config and dependencies
├── package-lock.json # Locked dependency versions
├── .gitignore        # Files to exclude from git
└── README.md
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
# Dependencies
node_modules/

# Environment variables
.env
.env.local

# OS files
.DS_Store
Thumbs.db

# Editor files
.vscode/
*.swp
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
VITE_API_URL=http://localhost:8000
DATABASE_URL=postgresql://localhost:5432/myapp
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