[Bug]: NPM error Container requiring root privs #1116

Closed
opened 2026-04-24 23:33:15 +02:00 by adam · 1 comment
Owner

Originally created by @wadebee on GitHub (Apr 30, 2023).

Describe the issue

Related to closed (abandoned) issue @ https://github.com/advplyr/audiobookshelf/issues/1183

npm ERR! Your cache folder contains root-owned files, due to a bug in
npm ERR! previous versions of npm which has since been addressed.

I've got this same issue trying to run this container in TrueNAS Scale (k3s orchestrator). By convention containers are running as uid/guid: 568.

As the error above mentions there appears to be a bug in npm so that any attempts to run this container as a non-root user fail.

Looking at the multi-stage Dockerfile I see that on line 5 the npm setup for the Build container is using
RUN npm ci && npm cache clean --force

But then on line 24 for the Runtime container you are using
RUN npm ci --only=production

Can this problem be corrected by changing line 24 to
RUN npm ci --only=production && npm cache clean --force

Refer to https://stackoverflow.com/questions/59437833/error-your-cache-folder-contains-root-owned-files-due-to-a-bug-in-previous-ver for some additional context

Steps to reproduce the issue

  1. When configuring the container for TrueNAS Scale set the runAsUser and runAsGroup to 568 under the Security Context settings.
  2. The Pod will fail deployment in a CrashLoopBackOff state.
  3. From a bash shell on TrueNas control plane run the
    kubectl logs {pod-name} -n ix-audiobookshelf command to review error

Error is:
wade@truenas:~$ oc logs audiobookshelf-d67cbf8b-wbw75

audiobookshelf@2.2.15 start
node index.js

npm ERR! code EACCES
npm ERR! syscall mkdir
npm ERR! path /.npm
npm ERR! errno -13
npm ERR!
npm ERR! Your cache folder contains root-owned files, due to a bug in
npm ERR! previous versions of npm which has since been addressed.
npm ERR!
npm ERR! To permanently fix this problem, please run:
npm ERR! sudo chown -R 568:568 "/.npm"

npm ERR! Log files were not written due to an error writing to the directory: /.npm/_logs
npm ERR! You can rerun the command with --loglevel=verbose to see the logs in your terminal

Audiobookshelf version

2.2.15

How are you running audiobookshelf?

Other

Originally created by @wadebee on GitHub (Apr 30, 2023). ### Describe the issue Related to closed (abandoned) issue @ https://github.com/advplyr/audiobookshelf/issues/1183 ``` npm ERR! Your cache folder contains root-owned files, due to a bug in npm ERR! previous versions of npm which has since been addressed. ``` I've got this same issue trying to run this container in TrueNAS Scale (k3s orchestrator). By convention containers are running as uid/guid: 568. As the error above mentions there appears to be a bug in npm so that any attempts to run this container as a non-root user fail. Looking at the multi-stage [Dockerfile](https://github.com/advplyr/audiobookshelf/blob/b707d6f3c9dc8ea3aa81408daa99ba10e60fccbd/Dockerfile) I see that on line 5 the npm setup for the _**Build**_ container is using `RUN npm ci && npm cache clean --force` But then on line 24 for the _**Runtime**_ container you are using `RUN npm ci --only=production` Can this problem be corrected by changing line 24 to `RUN npm ci --only=production && npm cache clean --force` Refer to https://stackoverflow.com/questions/59437833/error-your-cache-folder-contains-root-owned-files-due-to-a-bug-in-previous-ver for some additional context ### Steps to reproduce the issue 1. When configuring the container for TrueNAS Scale set the runAsUser and runAsGroup to 568 under the Security Context settings. 2. The Pod will fail deployment in a CrashLoopBackOff state. 3. From a bash shell on TrueNas control plane run the `kubectl logs {pod-name} -n ix-audiobookshelf` command to review error Error is: wade@truenas:~$ oc logs audiobookshelf-d67cbf8b-wbw75 > audiobookshelf@2.2.15 start > node index.js npm ERR! code EACCES npm ERR! syscall mkdir npm ERR! path /.npm npm ERR! errno -13 npm ERR! npm ERR! Your cache folder contains root-owned files, due to a bug in npm ERR! previous versions of npm which has since been addressed. npm ERR! npm ERR! To permanently fix this problem, please run: npm ERR! sudo chown -R 568:568 "/.npm" npm ERR! Log files were not written due to an error writing to the directory: /.npm/_logs npm ERR! You can rerun the command with `--loglevel=verbose` to see the logs in your terminal ### Audiobookshelf version 2.2.15 ### How are you running audiobookshelf? Other
adam added the bug label 2026-04-24 23:33:15 +02:00
adam closed this issue 2026-04-24 23:33:15 +02:00
Author
Owner

@advplyr commented on GitHub (Apr 30, 2023):

This was fixed in v2.2.17

I recommend you use the latest version 2.2.19

@advplyr commented on GitHub (Apr 30, 2023): This was fixed in [v2.2.17](https://github.com/advplyr/audiobookshelf/releases/tag/v2.2.17) I recommend you use the latest version 2.2.19
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/audiobookshelf#1116