Environment Setup: Node.js, Python, and Package Managers
Set up a professional development environment with version managers, virtual environments, and package managers. Stop fighting configuration and start building.
Why environment setup matters
The number one reason beginners give up on coding is not the code — it is the setup. Getting the right versions of the right tools installed and configured correctly is genuinely difficult. This guide eliminates that pain. We will install Node.js for JavaScript and Claude Code, Python for data science and scripting, and the package managers that keep your projects organized. More importantly, we will use version managers so you can switch between versions without breaking anything. A professional development environment has three properties: it is reproducible so you can set it up again on a new machine, it is isolated so one project's dependencies do not interfere with another, and it is documented so you or a teammate can understand the setup. By the end of this guide, you will have all three. If you have already installed Node.js and Python by downloading them from their websites, that works but is not ideal. Version managers give you much more control. This guide will explain how to transition from direct installs to managed ones without breaking your existing setup. The time you invest now in proper environment setup pays dividends for every project you build going forward.
Node.js with nvm: version management done right
nvm (Node Version Manager) lets you install and switch between multiple Node.js versions. This matters because different projects require different Node versions, and Claude Code itself needs a recent one. Install nvm on macOS or Linux with: `curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash`. Close and reopen your terminal, then verify: `nvm --version`. On Windows, use nvm-windows from the GitHub releases page. Install the latest LTS (Long Term Support) version of Node: `nvm install --lts`. This installs both Node.js and npm. Verify with: `node --version` and `npm --version`. You should see something like v20.11.0 and 10.2.0. To install a specific version: `nvm install 18` installs the latest Node 18. Switch between versions: `nvm use 18` or `nvm use 20`. Set a default: `nvm alias default 20`. Now every new terminal uses Node 20. Check installed versions: `nvm ls`. The arrow shows which is active. If a project needs Node 18 and your default is 20, just run `nvm use 18` in that project directory. You can also add a .nvmrc file to the project root containing just the version number like 18, then `nvm use` without arguments reads the file automatically. This is how professional teams ensure everyone uses the same Node version for a given project.
Python with pyenv: taming the snake
Python version management is notoriously confusing. macOS ships with an old Python. Many systems have both python2 and python3 commands. pyenv solves this cleanly. On macOS install it with: `brew install pyenv` (install Homebrew first from brew.sh if needed). On Linux use: `curl https://pyenv.run | bash`. After installation, add pyenv to your shell profile. For zsh on macOS, add these lines to ~/.zshrc: `export PYENV_ROOT="$HOME/.pyenv"` followed by `export PATH="$PYENV_ROOT/bin:$PATH"` followed by `eval "$(pyenv init -)"`. Restart your terminal and verify: `pyenv --version`. Install Python: `pyenv install 3.12`. This takes a few minutes as it compiles from source. Set it as your global default: `pyenv global 3.12`. Verify: `python --version` should show Python 3.12 with whatever patch version is current. For project-specific versions: `cd my-project && pyenv local 3.11` creates a .python-version file. Whenever you are in that directory, pyenv automatically switches to Python 3.11. Check installed versions: `pyenv versions`. If installation fails on macOS, you may need build dependencies: `brew install openssl readline sqlite3 xz zlib`. On Ubuntu: `sudo apt-get install -y make build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev`. These are the C libraries that Python compilation requires. Once pyenv is set up, you never need to worry about Python version conflicts again.
pip and virtual environments: project isolation
pip is Python's package manager, installed automatically with Python. Running `pip install requests` installs the requests library. But here is the problem: if you install packages globally, every Python project shares them. Project A needs requests version 2.28 and Project B needs version 2.31 — you cannot have both globally. Virtual environments solve this. Each project gets its own isolated set of packages. Create one with: `cd my-project && python -m venv venv`. This creates a venv directory containing a private Python installation. Activate it with: `source venv/bin/activate` on macOS and Linux or `venv\Scripts\activate` on Windows. Your prompt changes to show (venv), confirming you are in the virtual environment. Now `pip install requests` installs only for this project. Run `pip freeze > requirements.txt` to save your installed packages to a file. On another machine or after deleting venv, recreate the environment: `python -m venv venv && source venv/bin/activate && pip install -r requirements.txt`. Deactivate with: `deactivate`. Critical rules to remember: always add venv/ to .gitignore because you never commit the virtual environment directory. Always commit requirements.txt so others can recreate the environment. Always activate the virtual environment before working on the project. When Claude Code creates a Python project, it typically sets up a virtual environment for you. If it does not, ask it to create a virtual environment and requirements.txt for this project.
npm deep dive: packages, scripts, and lockfiles
npm manages JavaScript packages. Every Node.js project has a package.json file — create one with `npm init -y` where the -y flag accepts all defaults. The package.json has several important sections. The dependencies section lists packages your project needs to run: `npm install express` adds express to dependencies. The devDependencies section lists packages needed only for development: `npm install --save-dev typescript` adds TypeScript as a dev dependency. The scripts section defines custom commands. For example, you might have dev mapped to next dev, build mapped to next build, and start mapped to next start. Run them with `npm run dev`, `npm run build`, and so on. The start script is special — `npm start` works without the run keyword. When you run `npm install` in a project directory, npm reads package.json and downloads all listed packages into node_modules/. This folder is large, often hundreds of megabytes, and should never be committed to Git. Add node_modules/ to .gitignore. npm also creates package-lock.json, which records the exact version of every installed package and sub-dependency. This lockfile ensures everyone on the team gets identical versions. Always commit package-lock.json. Never edit it manually. Global installs using `npm install -g package-name` put packages in a system directory. Use this only for CLI tools like Claude Code that you use across all projects. Everything else should be a local project dependency.
Environment variables and .env files
Applications need configuration that changes between environments: API keys, database URLs, feature flags. Environment variables keep this configuration out of your code. Create a .env file in your project root with: `touch .env`. Add variables one per line like DATABASE_URL=postgres://localhost:5432/mydb, API_KEY=sk-your-key-here, NODE_ENV=development, and PORT=3000. For Node.js projects, install dotenv: `npm install dotenv`. Add require('dotenv').config() at the top of your entry file, or with Node 20 and above use the --env-file=.env flag. Your code accesses variables via process.env.API_KEY. For Python projects, install python-dotenv: `pip install python-dotenv`. Add from dotenv import load_dotenv followed by load_dotenv() at the top of your script. Access variables with os.environ['API_KEY']. For Next.js projects, .env files are loaded automatically. Variables prefixed with NEXT_PUBLIC_ are available in the browser; all others are server-only. Critical security rules: add .env to .gitignore before your first commit. Never commit API keys or passwords to Git. Create a .env.example file with placeholder values like API_KEY=your-key-here so teammates know which variables are needed without seeing the actual secrets. When deploying, set environment variables in your hosting platform's dashboard. Vercel, Railway, and similar platforms all have dedicated environment variable settings. The .env file is only for local development.
Putting it all together: the professional setup checklist
Here is your complete environment setup checklist. Run each command and verify the output. Version managers: `nvm --version` should show 0.39 or higher, `pyenv --version` should show 2.3 or higher. Runtimes: `node --version` should show v20 or higher, `python --version` should show 3.12 or higher. Package managers: `npm --version` should show 10 or higher, `pip --version` should show 23 or higher. Git: `git --version` should show 2.40 or higher. Claude Code: `claude --version` should show the latest version. Shell profile: check that your ~/.zshrc or ~/.bashrc contains the nvm and pyenv initialization lines. For each new project, follow this template: `mkdir project-name && cd project-name && git init`. Create a .gitignore file containing node_modules/, venv/, .env, and .DS_Store. For Node.js projects: `npm init -y`. For Python projects: `python -m venv venv && source venv/bin/activate`. Create .env and .env.example files. Make your first commit: `git add . && git commit -m 'Initial project setup'`. Start Claude Code: `claude`. Tell Claude Code about the project with something like: This is a Next.js project using TypeScript and Tailwind. I want to build a task management app. This checklist takes five minutes and saves hours of configuration headaches later. Bookmark this guide and run through the checklist every time you start a new project.
Your Development Environment
This guide is hands-on and practical. The full curriculum covers the conceptual foundations in depth with structured lessons and quizzes.
Go to lesson