Background image representing the theme of this page: Installing Node.js for local AI development.

Install Node.js

Step 4 — Prepare your environment for agent development.

Node.js gives you everything you need to build, run, and orchestrate local AI agents. In this step, you’ll install Node, verify your setup, and create your first project folder.

Install Node.js

Now that you’ve explored how different models perform on your machine, it’s time to set up the environment where your agent will actually live. Node.js is the foundation of your local‑first AI development workflow. It lets you write JavaScript that talks to your local models, interacts with tools, reads and writes files, and eventually orchestrates full autonomous loops.

Node is fast, lightweight, and supported everywhere. It’s also the ecosystem behind millions of applications — meaning your agent can integrate with almost anything. Installing it now prepares your system for the next step: building your first real AI agent.


macOS

On macOS, the easiest way to install Node.js is through Homebrew. This gives you automatic updates and a clean, system‑managed installation.

brew install node

Or download the official installer from the Node.js website:

https://nodejs.org/en/download


Windows

Windows users should install Node.js using the official MSI installer. Choose the LTS (Long‑Term Support) version for maximum stability.

https://nodejs.org/en/download

After installation, restart PowerShell or your terminal so the node and npm commands become available.


Linux

Most Linux distributions include Node.js in their package managers, but versions can vary. For a quick install:

sudo apt update sudo apt install nodejs npm

For newer versions, use the official NodeSource repository:

curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash - sudo apt install -y nodejs

Advanced users may prefer nvm (Node Version Manager), which lets you switch between Node versions easily.


Verify Installation

Check your Node.js version:

node -v

Check npm (Node’s package manager):

npm -v

If both commands return version numbers, your environment is ready for agent development.


Create Your Project Folder

Your agent needs a home — a folder where its code, tools, and configuration will live. Create one anywhere you like:

mkdir my-agent cd my-agent

Initialize a new Node project:

npm init -y

This generates a package.json file, which tracks your dependencies and scripts. It’s the heart of every Node project.


Install Dependencies

To connect your JavaScript agent to your local models, install the official Ollama JavaScript client:

npm install ollama

This library lets your agent send prompts, stream responses, and interact with any model you’ve installed.


Troubleshooting

“node: command not found”

  • Restart your terminal
  • Reinstall Node using the official installer

npm errors

  • Clear the cache: npm cache clean --force
  • Delete node_modules and reinstall

Permission issues (Linux)

  • Use sudo for system installs
  • Or install Node via nvm

Next Step
Build Your First Agent →