npx scripts fail
On a basic node:20 service, npx scripts won't run.
$ lando npx cowsay "Hello World" npm error code ENOENT npm error syscall lstat npm error path /var/www/.npm-global npm error errno -2 npm error enoent ENOENT: no such file or directory, lstat '/var/www/.npm-global' npm error enoent This is related to npm not being able to find a file. npm error enoent npm error A complete log of this run can be found in: /home/node/.npm/_logs/2025-03-05T18_25_08_720Z-debug-0.log
This is because npx tries to open .npm-global which doesn't exist in the container, and there is no error handling for that situation so it crashes.
Normally installing npx or any other global package would create that directory and there would be no issue, but since we're using the npx that comes with the container, that directory doesn't exist on a fresh image.