Repository: ghostfolio/ghostfolio

Issue #4282: [BUG] Seed command fails due to npx permission issue with npm cache
Created: 2025-02-04T13:58:19Z
Bug Description
Seed command fails due to npx permission issue with npm cache and Ghostfolio fails to start when trying to create a new instance of Ghostfolio.
To Reproduce
Start the container for a new environment using Portainer to create a stack (which also includes containers for redis and postgres)
My compose-file (stack file) is as follows
services:
  ghostfolio-redis:
    image: redis:alpine
    container_name: ghostfolio-redis
    security_opt:
      - no-new-privileges:true
    command: ['redis-server', '--requirepass', $REDIS_PASSWORD]
    healthcheck:
      test: ['CMD-SHELL', 'redis-cli --pass $REDIS_PASSWORD ping | grep PONG']
      interval: 10s
      timeout: 5s
      retries: 5
    networks:
      - internal
    environment:
      - TZ=Europe/London
    volumes:
      - ghostfolio-redis:/data
    restart: unless-stopped
  ghostfolio-postgres:
    image: postgres:15
    container_name: ghostfolio-postgres
    security_opt:
      - no-new-privileges:true
    healthcheck:
      test: ['CMD-SHELL', 'pg_isready -d $POSTGRES_DB -U $POSTGRES_USER']
      timeout: 45s
      interval: 10s
      retries: 10
    volumes:
      - ghostfolio-postgres:/var/lib/postgresql/data
    environment:
      - POSTGRES_DB=$POSTGRES_DB
      - POSTGRES_USER=$POSTGRES_USER
      - POSTGRES_PASSWORD=$POSTGRES_PASSWORD
    networks:
      - internal
    restart: unless-stopped
  ghostfolio-app:
    image: ghostfolio/ghostfolio:latest
    container_name: ghostfolio-app
    security_opt:
      - no-new-privileges:true
    environment:
      - DATABASE_URL=postgresql://$POSTGRES_USER:$POSTGRES_PASSWORD@ghostfolio-postgres:5432/$POSTGRES_DB?connect_timeout=300&sslmode=prefer
      - NODE_ENV=production
      - REDIS_HOST=ghostfolio-redis
      - REDIS_PORT=6379
      - REDIS_PASSWORD=$REDIS_PASSWORD
      - ACCESS_TOKEN_SALT=$ACCESS_TOKEN_SALT
      - JWT_SECRET_KEY=$JWT_SECRET_KEY
    ports:
      - 3333:3333
    networks:
      - internal
      - mediatools
    depends_on:
      ghostfolio-postgres:
        condition: service_started
      ghostfolio-redis:
        condition: service_healthy
    restart: unless-stopped

networks:
  mediatools:
    external: true
  internal:
    external: true
volumes:
  ghostfolio-redis:
  ghostfolio-postgres:

Expected behavior
The container to start cleanly with no errors.
Logs
The logs for the ghostfolio-app container include the following error
2025-02-04T13:54:26.564991441Z + echo Seeding the database
2025-02-04T13:54:26.565140987Z + npx prisma db seed
2025-02-04T13:54:26.565030288Z Seeding the database
2025-02-04T13:54:28.003765464Z Running seed command `npx ts-node --compiler-options {"module":"CommonJS"} prisma/seed.ts` ...
2025-02-04T13:54:29.384512960Z npm error code EACCES
2025-02-04T13:54:29.385063422Z npm error syscall mkdir
2025-02-04T13:54:29.385123045Z npm error path /.npm
2025-02-04T13:54:29.385157090Z npm error errno EACCES
2025-02-04T13:54:29.385242819Z npm error
2025-02-04T13:54:29.385273864Z npm error Your cache folder contains root-owned files, due to a bug in
2025-02-04T13:54:29.385324384Z npm error previous versions of npm which has since been addressed.
2025-02-04T13:54:29.385391127Z npm error
2025-02-04T13:54:29.385421479Z npm error To permanently fix this problem, please run:
2025-02-04T13:54:29.385460293Z npm error   sudo chown -R 1029:65537 "/.npm"
2025-02-04T13:54:29.386782538Z npm notice
2025-02-04T13:54:29.386950659Z npm notice New major version of npm available! 10.8.2 -> 11.1.0
2025-02-04T13:54:29.387013575Z npm notice Changelog: https://github.com/npm/cli/releases/tag/v11.1.0
2025-02-04T13:54:29.387054423Z npm notice To update run: npm install -g npm@11.1.0
2025-02-04T13:54:29.387088218Z npm notice
2025-02-04T13:54:29.387138095Z npm error Log files were not written due to an error writing to the directory: /.npm/_logs
2025-02-04T13:54:29.387191354Z npm error You can rerun the command with `--loglevel=verbose` to see the logs in your terminal
2025-02-04T13:54:29.400404548Z 
2025-02-04T13:54:29.400540525Z An error occurred while running the seed command:
2025-02-04T13:54:29.400918540Z Error: Command failed with exit code 1: npx ts-node --compiler-options {"module":"CommonJS"} prisma/seed.ts

Environment


Ghostfolio Version 2.137.1
Self-hosted
Experimental Features disabled
Browser N/A
OS - tried 2 different environments: Synology DSM 7.2.2-72806 Update 2/Container Manager 20.10.23-1437 and Ubuntu 24.04.1 LTS/Docker version 27.5.1, both with Portainer BE 2.21.5

Additional context

The postgres db is up and running and triggers this message at the point the db seed fails
2025-02-04T13:51:51.342193373Z 2025-02-04 13:51:51.342 UTC [95] LOG:  could not receive data from client: Connection reset by peer
redis is up and running with no messages.

Duplicate issue #4267: [BUG] Seed command fails in Ghostfolio 2.137.0
Created: 2025-02-01T15:42:49Z
Bug Description
Seeding the database fails.
To Reproduce

Run docker-compose up -d

Expected behavior
Server starts up without error.
Logs
Seeding the database

+ npx prisma db seed

Running seed command `ts-node --compiler-options {"module":"CommonJS"} prisma/seed.ts` ...

An error occurred while running the seed command:

Error: Command failed with ENOENT: ts-node --compiler-options {"module":"CommonJS"} prisma/seed.ts

spawn ts-node ENOENT

Environment


Ghostfolio Version 2.137.0
Self-hosted

Additional context
Introduced via #4248.

Closing comment (2025-02-04T14:11:43Z): @viktor-sc is your issue related to #4282?