PTENES
MODULE 2.2

📦 Installing Node.js and npm

Set up Node.js and npm—the alternative for creating MCP Servers in TypeScript.

6
Topics
20
Minutes
Basic
Level
Practical
Type
1

🌐 What Is Node.js

Node.js is a runtime that lets you run JavaScript outside the browser—directly on your computer or server. Created in 2009 by Ryan Dahl, it revolutionized web development by making it possible to use the same language on the frontend and backend. In the context of MCP, Node.js is essential for creating servers in TypeScript, the second most popular language in the MCP ecosystem.

💎 Core Concept

Node.js is a JavaScript runtime based on Chrome's V8 engine. It lets you run JavaScript and TypeScript code on the server, outside the browser. The official MCP SDK maintained by Anthropic is available in TypeScript (@modelcontextprotocol/sdk), making Node.js a powerful alternative to Python for creating MCP servers — especially for teams that already work with web technologies.

📊 Data and Research

Node.js is used by more than 6.3 million websites around the world. The npm registry has more than 2.1 million packages, the world's largest open-source package ecosystem. In the MCP ecosystem, many official servers—such as the filesystem server, GitHub server e Slack server — are written in TypeScript running on Node.js, demonstrating the platform's maturity for MCP.

2

📥 Installing Node.js

The recommended way to install Node.js is to use nvm (Node Version Manager), which lets you easily install and switch between multiple Node versions. This is especially useful when different projects require different versions. For MCP, we recommend Node.js 20 LTS (Long Term Support).

💎 Core Concept

O nvm (Node Version Manager) is a tool that manages multiple Node.js installations on the same computer. Instead of installing Node directly on the system (which can cause version conflicts), nvm installs each version in an isolated directory and lets you switch between them with a simple nvm use 20. This is analogous to what uv does for Python—isolated, controlled environments.

📋 Installation by Operating System
macOS / Linux — Step 1: Install nvm

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash

Close and reopen the terminal after installation.

macOS / Linux — Step 2: Install Node 20

nvm install 20

nvm installs Node.js 20 LTS and sets it as the default version.

Windows

Access nodejs.org and download the LTS installer. Run the installer with the default options. npm is installed automatically with Node.js.

🚨 Alert

Avoid installing Node.js via apt on Ubuntu! Ubuntu’s standard repositories often contain very old versions of Node.js (such as version 12 or 14). Always use nvm or the official NodeSource repository to make sure you get a current version that’s compatible with the MCP SDK.

3

📦 Understanding npm

O npm (Node Package Manager) is the package manager included with Node.js. Just as uv manages Python packages, npm manages JavaScript and TypeScript packages. It's responsible for installing dependencies, running scripts, and managing the file package.json — the equivalent of Python's pyproject.toml.

💎 Core Concept

O npm is three things at once: a registry (an online repository with millions of packages), a CLI (command-line tool for installing and managing packages) and a dependency manager (which manages versions via package.json and package-lock.json). When you install Node.js, npm is included — there is no need to install it separately.

💡 Practical Tip

Essential npm commands you’ll use in the course:

  • •npm init — Creates a new project (package.json)
  • •npm install pacote — Installs a dependency
  • •npm run script — Runs a script defined in package.json
  • •npm list — Lists packages installed in the project
4

🔧 Understanding npx

O npx is a tool that comes with npm and lets you run packages directly without installing them globally. This is especially important in the MCP ecosystem, where many servers run via npx — such as the filesystem server and the template creation server.

💎 Core Concept

O npx (Node Package Execute) downloads and runs a package temporarily, without installing it permanently on the system. This is essential for MCP because it lets you run servers such as npx @modelcontextprotocol/server-filesystem without cluttering your global environment. npx always fetches the latest package version, so you use the up-to-date version without having to manage updates manually.

❌ Avoid
  • •npm install -g @modelcontextprotocol/server-filesystem
  • •Install MCP servers globally
  • •Use outdated pinned versions
  • •Run with sudo npm install -g
✅ Do
  • •npx @modelcontextprotocol/server-filesystem
  • •Run MCP servers via npx
  • •Always use the latest version
  • •Keep the global environment clean
5

✅ Verifying the Installation

Just as we did with Python and uv, it’s essential to check that Node.js, npm, and npx are installed correctly and accessible in the terminal. Issues at this stage can cause confusing errors later, so it’s worth spending a few minutes checking.

💎 Core Concept

Verification confirms three components: the Node.js (JavaScript runtime), the npm (package manager) and the npx (package runner). All three should return their versions when queried via the terminal. If any of them fails, the problem is usually with the system PATH or an incomplete installation.

📋 Verification Checklist
Step 1 — Check Node.js

Execute node -v. It should show v20.x.x or higher.

Step 2 — Check npm

Execute npm -v. It should show the npm version (usually 10.x.x with Node 20).

Step 3 — Check npx

Execute npx --version. It should show the same npm version.

🚨 Alert — Common Problems
  • •"node: command not found" — If you used nvm, close and reopen the terminal. Check with nvm list whether Node was installed.
  • •Old version — If node -v shows v14 or v16, run nvm install 20 && nvm use 20.
  • •Permission denied — Never use sudo with npm. If it's asking for sudo, the installation wasn't done correctly — use nvm.
6

🧪 First Test

Let's run a hands-on test using the create-server official MCP — a template generator that creates the complete structure of an MCP Server in TypeScript. If this command works, your Node.js environment is 100% ready for the course.

💎 Core Concept

The package @modelcontextprotocol/create-server is an official generator that creates the complete structure of an MCP Server in TypeScript. It automatically generates the package.json, o tsconfig.json, the initial source code with examples of tools, resources, and prompts, as well as build and run scripts. It’s the equivalent of the uv init + uv add fastmcp of the Python world.

💡 Practical Tip

Run the command below in the terminal to create your first MCP Server in TypeScript:

npx @modelcontextprotocol/create-server meu-server

The generator will ask for the server's name and description. When it's done, enter the folder with cd meu-server and explore the generated files. If everything worked without errors, your Node.js environment is MCP-ready!

📝 Module Summary

  • ✓ Node.js is the runtime that lets you run JavaScript/TypeScript outside the browser—essential for MCP Servers in TS.
  • ✓ Installation via nvm is recommended because it lets you manage multiple Node versions without conflicts.
  • ✓ npm is included with Node.js and manages dependencies via package.json.
  • ✓ npx runs packages without a global installation—ideal for running MCP Servers.
  • ✓ Checking node -v, npm -v, and npx --version confirms that the environment is set up correctly.
  • ✓ The official create-server generates a complete MCP Server template in TypeScript.

Next Module: 2.3 — Getting to Know the Terminal