Skip to content

[BUG] npm package suddenly bloated #9220

@maddie-j

Description

@maddie-j

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

Our docker build suddenly exploded in size this week, and a quick poke with dive suggests our npm dependency may be the issue.

In the old docker image I have from before this problem, our apk add --no-cache pnpm wget npm step adds a total of 19MB to our docker image between all three dependencies. It seems the npm version used there was 11.12.0-r1, as reported by Docker Desktop.

However, today, running just apk add --no-cache npm in our image, after having split out the install step after having seen the large size jump, has the image jumping a whopping 270MB. This seems to be npm version 11.12.1-r4, as reported by Docker Desktop.

Using dive, it seems the newer version of npm is shipping with a whole bunch of additional and unnecessary stuff in its /usr/lib/node_modules/npm, that was trimmed from the earlier release. For example, there's 96MB from the .git folder that's newly shipping, the test folder is also now shipping, and npm's node_modules folder seems to be shipping with devDeps included, such as @babel and release-please.

Just looking at the version history of your package.json file, I can't see any obvious causes for the extra files being pulled in. But I also assume that, installing npm from the package manager in the docker image may be being bundled with tools different from how npm is usually bundled for distribution within itself.

Apologies for any typos and lack of screenshots/output dumps. I can't raise issues to external repos from my work computer, so am having to retype the relevant (and non-identifying/non-sensitive) info through my phone.

Expected Behavior

npm only ships to major package managers with the files required to run, with files such as the .git folder, tests, and devDeps excluded from the shipped app.

This is specifically for the context where npm is being added to a docker image to build a node app for deployment.

Steps To Reproduce

  1. In this environment...
  2. With this config...
  3. Run '...'
  4. See error...

Environment

  • npm: 11.12.1-r4
  • Node.js: 24.14.1-r0
  • OS Name: Wolfi
  • System Model Name: Docker
  • npm config:
; copy and paste output from `npm config ls` here

Metadata

Metadata

Assignees

No one assigned

    Labels

    Bugthing that needs fixingNeeds Triageneeds review for next steps

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions