n8n connects triggers and actions into workflows: take some data, transform it, then send the result somewhere useful. It suits recurring work that will eventually cross several services. If all you need is a one-off total, a spreadsheet or script is easier. Here you will start n8n on Windows, run an invoice workflow with a known result, and export it before adding credentials or an AI model.
Install locally with Docker on Windows
Use Docker Desktop with Linux containers and Docker Compose available. If Docker is not installed, follow Docker's Windows setup first. This walkthrough pins n8n 2.47.7 so the workflow and commands have a reproducible target; it is not a claim that this is the newest release.
In PowerShell, start with a new folder:
docker version
docker compose version
mkdir invoice-automation
cd invoice-automation
mkdir n8n-data, files
Save this as compose.yaml in invoice-automation:
services:
n8n:
image: docker.n8n.io/n8nio/n8n:2.47.7
ports:
- "127.0.0.1:${N8N_LOCAL_PORT:-5678}:5678"
environment:
TZ: Asia/Taipei
GENERIC_TIMEZONE: Asia/Taipei
N8N_DIAGNOSTICS_ENABLED: "false"
N8N_VERSION_NOTIFICATIONS_ENABLED: "false"
N8N_TEMPLATES_ENABLED: "false"
N8N_RUNNERS_MODE: internal
volumes:
- ./n8n-data:/home/node/.n8n
- ./files:/files
Start the service and check readiness:
docker compose up -d
docker compose ps
Invoke-RestMethod http://localhost:5678/healthz/readiness
Wait until this readiness request succeeds with status: ok; a connection error or non-200 response means wait a few seconds and retry. Do not stop the service while it is still initializing. The editor is at http://localhost:5678. This configuration binds only to your computer; the n8n-data folder retains the database and instance settings when the container is recreated. files is the shared folder used by the import/export commands below. The official Compose guide covers a newer, larger deployment stack; the small configuration here targets the tested 2.47.7 workflow.
The editor's first visit leads to owner setup. For a visual-editor introduction, use the official first-workflow tutorial. Continue below for a complete command-line workflow you can verify without completing that setup.
Stop the server before the one-off CLI commands. They use the same local data, so keep the service stopped throughout the next three workflows:
docker compose stop n8n
Your first workflow: paid invoices total 200
n8n passes records between nodes as items. Each item below has a json object containing an invoice, amount and payment status. The first Code node supplies three invoices; the second selects the paid ones and calculates their total. This makes it possible to tell whether the workflow is right, rather than merely whether it ran.
Save the complete JSON below as files/paid-invoices.json:
{
"id": "PaidInvoiceReport",
"name": "PaidInvoiceReport",
"active": false,
"nodes": [
{
"id": "start",
"name": "When clicking Execute",
"type": "n8n-nodes-base.manualTrigger",
"typeVersion": 1,
"position": [
0,
0
],
"parameters": {}
},
{
"id": "data",
"name": "Sample invoices",
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
220,
0
],
"parameters": {
"jsCode": "return [{json:{invoice:\"A\",amount:120,status:\"paid\"}},{json:{invoice:\"B\",amount:80,status:\"paid\"}},{json:{invoice:\"C\",amount:50,status:\"open\"}}];"
}
},
{
"id": "report",
"name": "Invoice report",
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
440,
0
],
"parameters": {
"jsCode": "const paid=$input.all().filter(x=>x.json.status===\"paid\"); return [{json:{count:paid.length,total:paid.reduce((n,x)=>n+x.json.amount,0)}}];"
}
}
],
"connections": {
"When clicking Execute": {
"main": [
[
{
"node": "Sample invoices",
"type": "main",
"index": 0
}
]
]
},
"Sample invoices": {
"main": [
[
{
"node": "Invoice report",
"type": "main",
"index": 0
}
]
]
}
},
"settings": {
"executionOrder": "v1"
}
}
Three practical uses
1. Calculate a paid-invoice summary
Import the workflow and execute it:
docker compose run --rm --no-deps n8n import:workflow --input=/files/paid-invoices.json
docker compose run --rm --no-deps n8n execute --id=PaidInvoiceReport --rawOutput
$LASTEXITCODE
The import should succeed. In the execution output, find the final Invoice report node's result: {"count":2,"total":200}, with exit 0. Invoices A=120 and B=80 are paid; C=50 is open and must not enter that total. Startup messages can appear before the execution JSON, so --rawOutput is not a promise that the entire console stream is a clean JSON document.
2. Produce the follow-up list
Copy files/paid-invoices.json to files/open-invoices.json. Change the top-level id and name to OpenInvoiceReport, then replace only the Invoice report node's jsCode with:
return $input.all().filter(x => x.json.status === "open");
docker compose run --rm --no-deps n8n import:workflow --input=/files/open-invoices.json
docker compose run --rm --no-deps n8n execute --id=OpenInvoiceReport --rawOutput
Expect exactly one final item: invoice C, amount 50, status open. Changing the workflow ID preserves the paid summary as a separate workflow. This is the same selection you can later place before a notification step.
3. Export a workflow for reuse
docker compose run --rm --no-deps n8n export:workflow --id=PaidInvoiceReport --output=/files/paid-invoices-export.json
Open files/paid-invoices-export.json on Windows. It should contain one workflow with all three nodes and the report code. Keep an export before experimenting; you can inspect changes and import the workflow into another compatible instance. An export is not a complete backup of the instance's database, credentials and encryption material.
When finished, you can start the editor again with docker compose up -d. Use docker compose stop n8n before repeating CLI operations against this same data folder.
If you use Codex to maintain the workflow, try: “Read paid-invoices.json. Explain why invoice C is excluded, run the import and execution commands with the server stopped, and check count=2 and total=200.” n8n runs independently of your coding assistant; the assistant can edit workflow JSON and run the CLI without an n8n MCP connection.
Errors and fixes
A successful health check, followed by a migration error
Use /healthz/readiness, not just /healthz. In one fresh Windows replay, the liveness endpoint returned OK before migrations finished; stopping immediately left the database incomplete, and import failed with Column "description" was not found in table "agents". The official monitoring reference distinguishes liveness from database readiness. If this happens in a disposable new tutorial instance, preserve the failed folder and repeat in a new folder, waiting for readiness; do not delete or reset an existing instance's data.
npm installation stalls or Docker cannot connect
Our npm download attempt timed out; the fixed official Docker image let us complete the workflow without depending on the host's Node installation. If docker version cannot reach the server, start Docker Desktop and wait for the Linux engine before retrying. Download failures are a network or registry issue: changing the workflow code will not solve them.
“The workflow with the id ... does not exist”
We reproduced this by executing MissingInvoiceReport. Run the import first and use the workflow's top-level id, not a node ID or its filename. Confirm that both commands mount the same n8n-data folder: importing into one instance does not populate another.
A Code node returns the wrong shape or throws an error
Return an array of items such as [{json:{total:200}}], rather than a bare number. The example uses the Code node's default all-items mode and $input.all() to aggregate records; see the Code node reference. In a separate negative test we deliberately threw an error and received Invoice amount must be a positive number [line 1]. That message came from our code, not a built-in invoice validator: add your own type and amount checks when processing real data.
Port 5678 is occupied, or a Python warning appears
For a busy host port, set $env:N8N_LOCAL_PORT='5679', rerun docker compose up -d and open port 5679 instead. The container still uses 5678 internally. Our JavaScript workflows completed even though the image warned that Python 3 was unavailable for its optional internal Python runner. A Python workflow needs a separately configured Python-capable runner; installing Python on the Windows host alone does not add it inside the container.
Cost, license and deployment limits
n8n's self-hosted community features are available under its Sustainable Use License, which permits personal and internal business use but restricts some ways of selling access to n8n. It is not the same license as MIT. Enterprise features, hosted services and the external APIs you connect can carry separate costs. Docker Desktop also has its own license terms.
A sleeping Windows computer cannot keep a scheduled workflow running. A localhost address also cannot receive an external webhook directly. For a continuously running service, follow the production requirements for security, access and backup planning instead of exposing this learning instance to the internet.
Choose LangGraph if you need code-defined agent state transitions rather than a visual integration workflow. If your task is only to extract a document's text before processing it, start with MarkItDown and keep the workflow as small as possible.
FAQ
How do I install n8n locally on Windows?
Run Docker Desktop with Linux containers, save the Compose configuration above, and run docker compose up -d. Check the health endpoint and open http://localhost:5678. The mounted data folder keeps instance data when the container is recreated.
Should I use Docker or npm for n8n?
Docker keeps n8n's runtime separate from the host's Node installation, which helped when our npm acquisition timed out. This walkthrough tests the fixed 2.47.7 image and uses Docker throughout. For a newer release, check its current installation guide rather than mixing npm instructions from another version with these commands.
Is local n8n free?
The community edition can be used within the Sustainable Use License's terms without an n8n subscription. That does not make connected model APIs, hosting or enterprise functionality free. Check Docker Desktop's terms too, especially for organizational use.
Can local n8n run an AI workflow?
It can connect workflow steps to models and other services, but running n8n locally does not automatically make the model local. The provider determines credentials, data handling and inference costs. First verify a simple data workflow such as this one, then follow the official documentation for your chosen model integration.
What we tested
On November 16, 2026, Codex on Windows invoked the real n8n 2.47.7 Linux Docker image to import, execute and export invoice workflows. The team verified paid total 200/count 2, one open invoice, export preservation and deliberate execution errors; the Compose startup and health check were also replayed. The inputs were synthetic invoices and the Code nodes used JavaScript. This was not native Windows npm execution, editor account setup, Python execution or an AI-model test. Official Docker, CLI and Code-node documentation was checked on the same date.