Introducing the SQLite3 Node for n8n

I’ve recently created a new node for n8n, that simplifies working with SQLite3 databases in your workflows. This node allows you to directly interact with SQLite3 databases, making it easier to access and manage your data without writing code.

Capabilities of the SQLite3 Node

  • Database Connection: Connect to multiple SQLite3 database by specifying the database file name and location.
  • Execute SQL Queries: Perform basic SQL operations like CREATE, SELECT, INSERT, UPDATE, and DELETE from within your n8n workflow.
  • Automate Data Operations: Use the node to automate interactions with your database, such as running queries on schedule, updating records, or retrieving information to use with other nodes in your workflow.

Maybe something similar already exists, I don’t know but honestly was a nice challenge to better understand how to create custom workflows.

This node is open-source and available on GitHub. If you’re interested, feel free to check it out and contribute!

Hope you enjoy my new node!

6 Likes

Hello folks,
i’ve updated this node to 0.2.0.
Hopes you enjoy the new error handling, and bugfixes!

2 Likes

@dangerblack the community node is broken after upgrading to 1.95.3 and it’s not possible to install it

1 Like

This post details a persistent issue installing the n8n-nodes-sqlite3 community node within an n8n Docker setup based on an Alpine Linux image (e.g., docker.n8n.io/n8nio/n8n), leading to the error: “Could not locate the bindings file.” I’ve found a reliable, albeit multi-step, workaround and have some insights that might help improve the underlying processes.

The Problem:

When n8n attempts to install n8n-nodes-sqlite3 (typically triggered by a user installing it via the Settings → Community Nodes → Install UI in n8n, or on startup if previously “installed” but broken), the installation of its critical native dependency, sqlite3, fails. This results in the error:

Error loading package "n8n-nodes-sqlite3": The specified package could not be loaded
Cause: Could not locate the bindings file. Tried: → /home/node/.n8n/nodes/node_modules/n8n-nodes-sqlite3/node_modules/sqlite3/build/node_sqlite3.node ... (and other paths)

Environment:

  • n8n Docker Image: docker.n8n.io/n8nio/n8n (Alpine based)
  • Node.js version (inside container): v20.19.2 (LTS)
  • n8n-nodes-sqlite3 tries to install [email protected]

Quick Workaround for Users:

If you’re facing this “Could not locate the bindings file” error for n8n-nodes-sqlite3 on your Alpine-based n8n Docker setup, this multi-step workaround was successful:

Step 1: Prepare Your Docker Environment with Build Tools

  1. Create a Dockerfile in the same directory as your docker-compose.yml:

    # Use your current n8n image as the base
    FROM docker.n8n.io/n8nio/n8n
    
    USER root
    # Add essential build tools for compiling native Node.js modules
    RUN apk add --no-cache python3 py3-setuptools make g++
    USER node
    
  2. Modify your docker-compose.yml to build from this Dockerfile:

    version: "3.7" # Or your version
    services:
      n8n:
        build:
          context: . # Tells Docker Compose to look for the Dockerfile here
        # image: docker.n8n.io/n8nio/n8n # Comment out or remove the direct image line
        restart: always
        # Add any other necessary environment variables for n8n.
        # ... rest of your n8n service configuration (ports, volumes)
    # ... rest of your docker-compose.yml
    
  3. Rebuild and start your n8n container:

    docker-compose down # Optional if already running, but recommended for a clean start
    docker-compose up -d --build
    

    Your n8n image now has the necessary build tools. n8n will start, but n8n-nodes-sqlite3 will likely still be failing if you had previously tried to install it via the UI, or it won’t be available yet.

Step 2: Manually Install n8n-nodes-sqlite3 Package Structure and Then Its Dependencies Inside the Container

  1. Shell into your running n8n container:

    docker-compose exec n8n /bin/sh
    
  2. Navigate to n8n’s primary directory for externally installed nodes:

    # Ensure the base 'nodes' directory exists
    mkdir -p /home/node/.n8n/nodes/
    cd /home/node/.n8n/nodes/
    
  3. Manually install the n8n-nodes-sqlite3 package into this nodes directory. This crucial step creates the base package structure /home/node/.n8n/nodes/node_modules/n8n-nodes-sqlite3/.

    # Clean any potential leftover lock file in this parent directory to avoid conflicts
    rm -f package-lock.json
    npm install n8n-nodes-sqlite3 --verbose
    

    This command should complete relatively quickly and report “ok”. It installs the main n8n-nodes-sqlite3 package files but its internal sqlite3 dependency will likely not be correctly built or present yet.

  4. Navigate into the freshly created n8n-nodes-sqlite3 package directory:

    cd /home/node/.n8n/nodes/node_modules/n8n-nodes-sqlite3/
    

    If this directory does not exist after the npm install n8n-nodes-sqlite3 command in Step 2.3, then the installation of the main package itself failed. Review the output of that command carefully.

  5. Clean up any partial internal dependencies and force a proper install of its dependencies (this crucial step will compile sqlite3):

    rm -rf node_modules package-lock.json
    npm install --verbose --build-from-source
    

    (This npm install command can take 4-5 minutes as sqlite3 compiles from source using the tools added to your Docker image).

  6. Once the command completes successfully (you should see “npm info ok”), exit the container shell:

    exit
    
  7. Restart n8n one final time. This allows n8n to discover and load the now-correctly-built node:

    docker-compose restart n8n
    

The n8n-nodes-sqlite3 node should now be available and functional in your n8n workflows. If you hadn’t previously “told” n8n to install it via the UI, you might need to do so now for n8n to fully recognize it (or simply restarting might be enough for n8n to scan the nodes/node_modules directory).


Detailed Investigation & Insights (for Developers & Maintainers):

A. Initial State & Problem:
The core issue is that sqlite3 (a native Node.js addon and dependency of n8n-nodes-sqlite3) was not being installed correctly during n8n’s community node installation process (typically triggered from the n8n UI or on startup if n8n is configured to load it).

  • Pre-built binaries for [email protected] do exist for linuxmusl-x64 (Alpine) according to its GitHub Releases (e.g., sqlite3-v5.1.7-napi-v6-linuxmusl-x64.tar.gz).
  • However, the n8n-managed installation process appeared to:
    1. Fail to download or correctly utilize these pre-built binaries.
    2. Subsequently fail to compile sqlite3 from source because the stock n8n Alpine image lacked necessary build tools (python3, make, g++, py3-setuptools).
    3. Crucially, n8n’s npm process often failed to even create the /home/node/.n8n/nodes/node_modules/n8n-nodes-sqlite3/ directory or, if it did, it would not correctly install sqlite3 into its internal node_modules.

B. The Successful Manual Intervention (Workaround Step 2):
The breakthrough required a two-stage manual npm install process after preparing the Docker image with build tools:

  1. First, manually running npm install n8n-nodes-sqlite3 within the parent /home/node/.n8n/nodes/ directory. This was necessary to create the base package structure /home/node/.n8n/nodes/node_modules/n8n-nodes-sqlite3/.
  2. Second, cd-ing directly into this newly created package directory and running npm install --build-from-source there. This explicitly forced npm to process the package.json of n8n-nodes-sqlite3 and correctly install and compile its dependencies, notably sqlite3.

C. Current Status after Workaround:

  • The n8n-nodes-sqlite3 node is now functional in workflows.
  • It does not appear in the “Community Nodes” list in the n8n Settings UI (if the initial UI install failed and was never re-attempted or “fixed” from n8n’s perspective). This is likely because n8n’s own managed installation process didn’t register a “clean” success, and our fix was external to that.

Points for Consideration & Potential Improvements:

  1. For n8n Core Developers:

    • Community Node Installation Robustness: Investigate why npm (as invoked by n8n when installing community nodes, e.g., via the UI) might fail to:
      • Reliably create the base package directory for the community node.
      • Subsequently install transitive native dependencies (like sqlite3 for n8n-nodes-sqlite3) correctly within the community node’s own node_modules directory.
    • Error Reporting: Enhance error messages when community node installation fails. Instead of just “Could not locate bindings file,” could n8n capture and display more of the underlying npm or node-gyp build errors, or errors indicating the initial package installation failed?
    • Installation Timeouts: Review if there are timeouts for community node installations that might be too short for native modules requiring compilation.
    • Alpine Build Tools (Consideration): Consider if the official n8n Alpine image should include common build tools by default, or provide a tagged variant.
  2. For n8n-nodes-sqlite3 Maintainers:

    • Documentation: Consider adding a note to your README about potential build tool requirements and this more involved manual installation workaround for Docker/Alpine users.
2 Likes

you are great!

1 Like

This is a brilliant write up of the problem. Can we get an official fix please? :smiley:

EDIT: @nukeador following your steps I can get the community node working/installed behind the scenes, but then in the GUI if I try and install it I get the error message:

Error loading package "n8n-nodes-sqlite3" :The specified package could not be loaded Cause: ENOENT: no such file or directory, open '/home/node/.n8n/nodes/node_modules/n8n-nodes-sqlite3/node_modules/bindings/bindings.js' 

And then n8n nukes the whole /home/node/.n8n/nodes/node_modules/n8n-nodes-sqlite3 directory…

I guess it should be looking in /home/node/.n8n/nodes/node_modules/bindings/bindings.js???

Not sure what’s happening there. I am using volume mount:

  - /home/myname/docker/n8n:/home/node/.n8n

Which should be correct?

Anyway thanks again.

1 Like

It’s very difficult to patch node dependency hell is kinda a mess, I’ll probably try something, i really not want to force all of you to change the docker image you are using.
nukeador proposal are good, but I would like to find a fix for the dependencies, I need to study a little more.

2 Likes

Just saw your updates on git, sorry I can’t be of more help :frowning: keep up the good work bro!

1 Like