Skip to content

npm installation failing with "Error: Cannot find module 'mysql'" #4837

@scottsuch

Description

@scottsuch

Checklist

  • Have you pulled and found the error with jc21/nginx-proxy-manager:latest docker image?
    • Yes
  • Are you sure you're not using someone else's docker image?
    • Yes
  • Have you searched for similar issues (both open and closed)?
    • Yes

Describe the bug

It seems there is a missing dependency for mysql backed installations when upgrading to the latest.

logs
sgorsuch@matrix:~/docker/npm$ docker compose up -d
[+] Running 2/2
 ⠿ Container npm_db  Started                                                                                                                                                                                                                            0.2s
 ⠿ Container npm     Started                                                                                                                                                                                                                            0.3s
sgorsuch@matrix:~/docker/npm$ docker logs npm
❯ Configuring npm user ...
❯ Configuring npm group ...
❯ Checking paths ...
❯ Setting ownership ...
- /data ...
    SKIPPED
- /etc/letsencrypt ...
    SKIPPED
- /run/nginx ...
    DONE
- /tmp/nginx ...
    DONE
- /var/cache/nginx ...
    DONE
- /var/lib/logrotate ...
    DONE
- /var/lib/nginx ...
    DONE
- /var/log/nginx ...
    DONE
- /etc/nginx/nginx ...
    DONE
- /etc/nginx/nginx.conf ...
    DONE
- /etc/nginx/conf.d ...
    DONE
❯ Changing ownership of certbot directories, this may take some time ...
- /opt/certbot ...
    DONE
- /opt/certbot/bin ...
    DONE
- /opt/certbot/lib/python3.11/site-packages ...
sgorsuch@matrix:~/docker/npm$ docker logs -f npm
❯ Configuring npm user ...
❯ Configuring npm group ...
❯ Checking paths ...
❯ Setting ownership ...
- /data ...
    SKIPPED
- /etc/letsencrypt ...
    SKIPPED
- /run/nginx ...
    DONE
- /tmp/nginx ...
    DONE
- /var/cache/nginx ...
    DONE
- /var/lib/logrotate ...
    DONE
- /var/lib/nginx ...
    DONE
- /var/log/nginx ...
    DONE
- /etc/nginx/nginx ...
    DONE
- /etc/nginx/nginx.conf ...
    DONE
- /etc/nginx/conf.d ...
    DONE
❯ Changing ownership of certbot directories, this may take some time ...
- /opt/certbot ...
    DONE
- /opt/certbot/bin ...
    DONE
- /opt/certbot/lib/python3.11/site-packages ...
    DONE
❯ Dynamic resolvers ...
❯ IPv6 ...
Enabling IPV6 in hosts in: /etc/nginx/conf.d
- /etc/nginx/conf.d/default.conf
- /etc/nginx/conf.d/production.conf
- /etc/nginx/conf.d/include/block-exploits.conf
- /etc/nginx/conf.d/include/ssl-ciphers.conf
- /etc/nginx/conf.d/include/ssl-cache-stream.conf
- /etc/nginx/conf.d/include/ip_ranges.conf
- /etc/nginx/conf.d/include/log.conf
- /etc/nginx/conf.d/include/ssl-cache.conf
- /etc/nginx/conf.d/include/assets.conf
- /etc/nginx/conf.d/include/force-ssl.conf
- /etc/nginx/conf.d/include/letsencrypt-acme-challenge.conf
- /etc/nginx/conf.d/include/proxy.conf
- /etc/nginx/conf.d/include/resolvers.conf
Enabling IPV6 in hosts in: /data/nginx
- /data/nginx/proxy_host/31.conf
- /data/nginx/proxy_host/21.conf
- /data/nginx/proxy_host/24.conf
- /data/nginx/proxy_host/25.conf
- /data/nginx/proxy_host/20.conf
- /data/nginx/proxy_host/23.conf
- /data/nginx/proxy_host/26.conf
- /data/nginx/proxy_host/4.conf
- /data/nginx/proxy_host/32.conf
- /data/nginx/proxy_host/6.conf
- /data/nginx/proxy_host/19.conf
- /data/nginx/proxy_host/22.conf
- /data/nginx/proxy_host/10.conf
- /data/nginx/proxy_host/9.conf
- /data/nginx/proxy_host/3.conf
- /data/nginx/proxy_host/5.conf
- /data/nginx/proxy_host/7.conf
- /data/nginx/proxy_host/16.conf
- /data/nginx/proxy_host/8.conf
- /data/nginx/proxy_host/11.conf
- /data/nginx/proxy_host/33.conf
- /data/nginx/proxy_host/2.conf
- /data/nginx/default_host/site.conf
❯ Docker secrets ...

-------------------------------------
 _   _ ____  __  __
| \ | |  _ \|  \/  |
|  \| | |_) | |\/| |
| |\  |  __/| |  | |
|_| \_|_|   |_|  |_|
-------------------------------------
User:  npm PUID:1000 ID:1000 GROUP:1000
Group: npm PGID:1000 ID:1000
-------------------------------------

❯ Starting nginx ...
❯ Starting backend ...
nginx: [warn] the "user" directive makes sense only if the master process runs with super-user privileges, ignored in /etc/nginx/nginx.conf:4
nginx: [warn] the "listen ... http2" directive is deprecated, use the "http2" directive instead in /data/nginx/proxy_host/10.conf:14
nginx: [warn] the "listen ... http2" directive is deprecated, use the "http2" directive instead in /data/nginx/proxy_host/10.conf:15
nginx: [warn] the "listen ... http2" directive is deprecated, use the "http2" directive instead in /data/nginx/proxy_host/11.conf:19
nginx: [warn] protocol options redefined for 0.0.0.0:443 in /data/nginx/proxy_host/11.conf:19
nginx: [warn] the "listen ... http2" directive is deprecated, use the "http2" directive instead in /data/nginx/proxy_host/11.conf:20
nginx: [warn] protocol options redefined for [::]:443 in /data/nginx/proxy_host/11.conf:20
nginx: [warn] the "listen ... http2" directive is deprecated, use the "http2" directive instead in /data/nginx/proxy_host/16.conf:19
nginx: [warn] the "listen ... http2" directive is deprecated, use the "http2" directive instead in /data/nginx/proxy_host/16.conf:20
nginx: [warn] the "listen ... http2" directive is deprecated, use the "http2" directive instead in /data/nginx/proxy_host/19.conf:14
nginx: [warn] the "listen ... http2" directive is deprecated, use the "http2" directive instead in /data/nginx/proxy_host/19.conf:15
nginx: [warn] the "listen ... http2" directive is deprecated, use the "http2" directive instead in /data/nginx/proxy_host/2.conf:14
nginx: [warn] the "listen ... http2" directive is deprecated, use the "http2" directive instead in /data/nginx/proxy_host/2.conf:15
nginx: [warn] the "listen ... http2" directive is deprecated, use the "http2" directive instead in /data/nginx/proxy_host/20.conf:14
nginx: [warn] the "listen ... http2" directive is deprecated, use the "http2" directive instead in /data/nginx/proxy_host/20.conf:15
nginx: [warn] the "listen ... http2" directive is deprecated, use the "http2" directive instead in /data/nginx/proxy_host/21.conf:14
nginx: [warn] the "listen ... http2" directive is deprecated, use the "http2" directive instead in /data/nginx/proxy_host/21.conf:15
nginx: [warn] the "listen ... http2" directive is deprecated, use the "http2" directive instead in /data/nginx/proxy_host/22.conf:19
nginx: [warn] the "listen ... http2" directive is deprecated, use the "http2" directive instead in /data/nginx/proxy_host/22.conf:20
nginx: [warn] the "listen ... http2" directive is deprecated, use the "http2" directive instead in /data/nginx/proxy_host/23.conf:14
nginx: [warn] the "listen ... http2" directive is deprecated, use the "http2" directive instead in /data/nginx/proxy_host/23.conf:15
nginx: [warn] the "listen ... http2" directive is deprecated, use the "http2" directive instead in /data/nginx/proxy_host/24.conf:14
nginx: [warn] the "listen ... http2" directive is deprecated, use the "http2" directive instead in /data/nginx/proxy_host/24.conf:15
nginx: [warn] protocol options redefined for 0.0.0.0:443 in /data/nginx/proxy_host/25.conf:19
nginx: [warn] protocol options redefined for [::]:443 in /data/nginx/proxy_host/25.conf:20
nginx: [warn] the "listen ... http2" directive is deprecated, use the "http2" directive instead in /data/nginx/proxy_host/26.conf:14
nginx: [warn] protocol options redefined for 0.0.0.0:443 in /data/nginx/proxy_host/26.conf:14
nginx: [warn] the "listen ... http2" directive is deprecated, use the "http2" directive instead in /data/nginx/proxy_host/26.conf:15
nginx: [warn] protocol options redefined for [::]:443 in /data/nginx/proxy_host/26.conf:15
nginx: [warn] the "listen ... http2" directive is deprecated, use the "http2" directive instead in /data/nginx/proxy_host/3.conf:14
nginx: [warn] the "listen ... http2" directive is deprecated, use the "http2" directive instead in /data/nginx/proxy_host/3.conf:15
nginx: [warn] the "listen ... http2" directive is deprecated, use the "http2" directive instead in /data/nginx/proxy_host/31.conf:19
nginx: [warn] the "listen ... http2" directive is deprecated, use the "http2" directive instead in /data/nginx/proxy_host/31.conf:20
nginx: [warn] protocol options redefined for 0.0.0.0:443 in /data/nginx/proxy_host/32.conf:19
nginx: [warn] protocol options redefined for [::]:443 in /data/nginx/proxy_host/32.conf:20
nginx: [warn] the "listen ... http2" directive is deprecated, use the "http2" directive instead in /data/nginx/proxy_host/4.conf:14
nginx: [warn] protocol options redefined for 0.0.0.0:443 in /data/nginx/proxy_host/4.conf:14
nginx: [warn] the "listen ... http2" directive is deprecated, use the "http2" directive instead in /data/nginx/proxy_host/4.conf:15
nginx: [warn] protocol options redefined for [::]:443 in /data/nginx/proxy_host/4.conf:15
nginx: [warn] the "listen ... http2" directive is deprecated, use the "http2" directive instead in /data/nginx/proxy_host/5.conf:14
nginx: [warn] the "listen ... http2" directive is deprecated, use the "http2" directive instead in /data/nginx/proxy_host/5.conf:15
nginx: [warn] protocol options redefined for 0.0.0.0:443 in /data/nginx/proxy_host/6.conf:19
nginx: [warn] protocol options redefined for [::]:443 in /data/nginx/proxy_host/6.conf:20
nginx: [warn] the "listen ... http2" directive is deprecated, use the "http2" directive instead in /data/nginx/proxy_host/7.conf:14
nginx: [warn] protocol options redefined for 0.0.0.0:443 in /data/nginx/proxy_host/7.conf:14
nginx: [warn] the "listen ... http2" directive is deprecated, use the "http2" directive instead in /data/nginx/proxy_host/7.conf:15
nginx: [warn] protocol options redefined for [::]:443 in /data/nginx/proxy_host/7.conf:15
nginx: [warn] the "listen ... http2" directive is deprecated, use the "http2" directive instead in /data/nginx/proxy_host/8.conf:14
nginx: [warn] the "listen ... http2" directive is deprecated, use the "http2" directive instead in /data/nginx/proxy_host/8.conf:15
nginx: [warn] the "listen ... http2" directive is deprecated, use the "http2" directive instead in /data/nginx/proxy_host/9.conf:14
nginx: [warn] the "listen ... http2" directive is deprecated, use the "http2" directive instead in /data/nginx/proxy_host/9.conf:15
[11/4/2025] [3:47:54 PM] [Global   ] › ℹ  info      Using configuration from file: ./config/production.json
Knex: run
$ npm install mysql --save
Cannot find module 'mysql'
Require stack:
- /app/node_modules/knex/lib/dialects/mysql/index.js
- /app/node_modules/knex/lib/dialects/index.js
- /app/node_modules/knex/lib/knex-builder/internal/config-resolver.js
- /app/node_modules/knex/lib/knex-builder/Knex.js
- /app/node_modules/knex/lib/index.js
- /app/node_modules/knex/knex.js
Error: Cannot find module 'mysql'
Require stack:
- /app/node_modules/knex/lib/dialects/mysql/index.js
- /app/node_modules/knex/lib/dialects/index.js
- /app/node_modules/knex/lib/knex-builder/internal/config-resolver.js
- /app/node_modules/knex/lib/knex-builder/Knex.js
- /app/node_modules/knex/lib/index.js
- /app/node_modules/knex/knex.js
    at Function._resolveFilename (node:internal/modules/cjs/loader:1383:15)
    at defaultResolveImpl (node:internal/modules/cjs/loader:1025:19)
    at resolveForCJSWithHooks (node:internal/modules/cjs/loader:1030:22)
    at Function._load (node:internal/modules/cjs/loader:1192:37)
    at TracingChannel.traceSync (node:diagnostics_channel:328:14)
    at wrapModuleLoad (node:internal/modules/cjs/loader:237:24)
    at Module.require (node:internal/modules/cjs/loader:1463:12)
    at require (node:internal/modules/helpers:147:16)
    at Client_MySQL._driver (/app/node_modules/knex/lib/dialects/mysql/index.js:23:12)
    at Client_MySQL.initializeDriver (/app/node_modules/knex/lib/client.js:190:26)
/app/node_modules/knex/lib/client.js:194
      throw new Error(`${message}\n${e.message}`);

Nginx Proxy Manager Version

v2.13.0

To Reproduce
Steps to reproduce the behavior:

  1. Pull latest docker image
  2. Run docker compose up -d
  3. Run docker logs -f <container_name>
  4. See error in logs above

Expected behavior

Screenshots

Nothing to screenshot sadly, just a blank page in chrome when navigating to the UI.

Operating System

My installation is running in a docker container on Ubuntu 22.04.

Additional context

docker-compose.yaml
---
version: "3"

services:
  app:
    container_name: npm
    hostname: ${NPM_HOSTNAME}
    image: jc21/nginx-proxy-manager:latest
    restart: always
    ports:
      - "80:80"     # Public HTTP Port
      - "443:443"   # Public HTTPS Port
      - "81:81"     # Admin Web Port
    environment:
      DB_MYSQL_HOST: db
      DB_MYSQL_PORT: 3306
      DB_MYSQL_USER: npm
      DB_MYSQL_PASSWORD: ${MYSQL_PASSWORD}
      DB_MYSQL_NAME: npm
      PGID: ${PGID}
      PUID: ${PUID}
      TZ: ${TZ}
      VIRTUAL_HOST: ${NPM_HOSTNAME}
      X_FRAME_OPTIONS: sameorigin
    volumes:
      - "./config.json:/app/config/production.json"
      - "./data:/data"
      - "./letsencrypt:/etc/letsencrypt"
    depends_on:
      - db

  db:
    image: jc21/mariadb-aria:latest
    container_name: npm_db
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}
      MYSQL_DATABASE: npm
      MYSQL_USER: npm
      MYSQL_PASSWORD: ${MYSQL_PASSWORD}
    volumes:
      - "./data/mysql:/var/lib/mysql"

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions