Skip to content

[BUG] npm exits silently with the code 254 and read only filesystem #4838

Closed
@svsool

Description

@svsool

Is there an existing issue for this?

  • I have searched the existing issues

This issue exists in the latest npm version

  • I am using the latest npm

Current Behavior

I use npm 8.6.0 and when I exec into Kubernetes pod and run npm --version npm exits silently. Then running echo $? prints 254. It used to work fine with npm 8.5.5, read only file system and mentioned below security context config.

image

Expected Behavior

I expect that npm --version will run fine.

Steps To Reproduce

  1. Create a static pod in the Kubernetes cluster using the following yaml:
apiVersion: v1
kind: Pod
metadata:
  name: node-test
spec:
  containers:
  - name: node-test-pod
    image: node:18.0.0-alpine
    command:
    - tail
    - "-f"
    - /dev/null
    securityContext:
      allowPrivilegeEscalation: false
      capabilities:
        drop:
          - AUDIT_WRITE
          - CHOWN
          - DAC_OVERRIDE
          - FOWNER
          - FSETID
          - KILL
          - MKNOD
          - NET_BIND_SERVICE
          - NET_RAW
          - SETFCAP
          - SETGID
          - SETPCAP
          - SETUID
          - SYS_CHROOT
      privileged: false
      readOnlyRootFilesystem: true <------ this is important to reproduce a bug
      runAsNonRoot: true
      runAsUser: 1000
  1. Run kubectl exec -it <pod_name> -- /bin/sh
  2. Run npm --version
  3. It should fail silently

Environment

  • npm: 8.6.0
  • Node.js: v18.0.0
  • OS Name: Alpine Linux v3.15
  • System Model Name:
  • npm config:
; node bin location = /usr/local/bin/node
; cwd = /app
; HOME = /home/node
; Run `npm config ls -l` to show all defaults.

Metadata

Metadata

Assignees

Labels

Bugthing that needs fixingPriority 1high priority issueRelease 8.xwork is associated with a specific npm 8 release

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions