Run "npm install" in docker container

I wanted to fix a Wordpress bug and cloned their git repository, setup the Apache vhost and saw:

You are running WordPress without JavaScript and CSS files. These need to be built.

Before running any build tasks you need to make sure the dependencies are installed. You can install these by running npm install.

So I an apt install npm on my Debian 13 system, downloaded 188 MiB of files and then got...

$ npm install
npm ERR! code EBADENGINE
npm ERR! engine Unsupported engine
npm ERR! engine Not compatible with your version of node/npm: WordPress@7.1.0
npm ERR! notsup Not compatible with your version of node/npm: WordPress@7.1.0
npm ERR! notsup Required: {"node":">=20.10.0","npm":">=10.2.3"}
npm ERR! notsup Actual:   {"npm":"9.2.0"}
 
npm ERR! A complete log of this run can be found in:
npm ERR!     /home/cweiske/.npm/_logs/2026-04-03T16_58_36_196Z-debug-0.log
 
$ node --version
v20.19.2
$ npm --version
9.2.0

Of course it is too old. Even when I install an npm or node version released yesterday, it's outdated tomorrow.

I will not run their shitty curl totally.legit/script.sh | sudo bash install script and flood my system with files I'll never get removed. Instead I downloaded the latest node docker container and used it:

$ docker pull node:trixie
$ docker run --rm -it --volume $(pwd):/build --workdir /build --user $(id -u):$(id -g) node:trixie npm install
$ docker run --rm -it --volume $(pwd):/build --workdir /build --user $(id -u):$(id -g) node:trixie npm run build

This mounts the current directory into the container, and runs npm as with my local user and group IDs - so that the permissions of generated files and directories are correct.

This built all the javascript dependencies. Now I have this:

$ du -hs node_modules/
863M	node_modules/
 
$ docker run [...] node:trixie npm list -a | wc -l
5000

That's what you get when using a programming language without a standard library.

Btw, I had to point the Apache vhost to the wordpress/build/ folder instead of wordpress/src/ - otherwise it would not detect the compiled javascript files.

Written by Christian Weiske.

Comments? Please send an e-mail.