Skip to content

Using Claude Code with Legacy Node Projects

Published:  at 06:16 PM
Table of Contents

Problem

Simple solution is open that project in a docker container. By containerizing your legacy application, you can maintain a modern Node version on your host machine for Claude Code while running your old project in an isolated environment.

Step1: Configure Your Host Environment

First, set up a modern Node version so Claude Code can run properly. Create or update your .node-version file in your project directory:

22.20.0

Or even somewhere else like a parent directory one level above is fine. Claude Code will find and use it either way.

Step2: Create a Docker Container

Now you’ll containerize your legacy application. Here’s an example for an ancient Nuxt version2 project running on Node 10 (yes, it’s the Ice Age software).

dockerfile

FROM node:10.22.0

WORKDIR /app

# Copy package files
COPY package*.json ./
COPY yarn.lock* ./

# Install dependencies
RUN yarn install

# Copy .env file
COPY .env* ./

# Expose the port that Nuxt dev server runs on
EXPOSE 9000

# Start the development server

# Start the development server
# Note: --hostname 0.0.0.0 is required to make the server accessible from outside the container
# Instead of CMD ["yarn", "dev"]
CMD ["sh", "-c", "yarn install && yarn nuxt-ts --port 9000 --hostname 0.0.0.0"]

docker-compose.yml

version: "3.8"

services:
  nuxt-app:
    build: .
    ports:
      - "9000:9000"
    volumes:
      # Share source code with the container
      - .:/app
      # Use container's node_modules (don't override with host)
      - /app/node_modules
    environment:
      - NODE_ENV=development
    stdin_open: true
    tty: true

Then just normally docker-compose.

docker-compose up --build -d

Now you have both Claude Code and a legacy project up and running.

Other Solution

Or if it’s a simple project and you don’t even have to create a docker container, you can simply

  1. Open the project from a parent directory
  2. Open Claude in the parent directory
  3. Let the Claude work in the child directory from there