When testing CI Dockerfiles locally, most npm command start or ends with:
┌──────────────────────────────────────────────────────────┐ │ npm update check failed │ │ Try running with sudo or get access │ │ to the local update config store via │ │ sudo chown -R $USER:$(id -gn $USER) /nonexistent/.config │ └──────────────────────────────────────────────────────────┘
This comes from a package called update-notifier (source) which npm-cli uses to check once a day (at most) whether a new npm version is available.
This check is automatically skipped by npm if it detects that it is in a CI environment (source, issue), which is triggered by an environment variable like CI=true, or one of several popular CI runners (including Jenkins, and Travis; docs).
However, our CI envs aren't part of the Dockerfile, and so the update check is tried, and then fails.
Now, the npm cache logic (which uses $HOME/.npm by default, which we had to override in our images via NPM_CONFIG_cache) does not support XDG base dirs.
But.. the update notification system does support it. It checks XDG_CONFIG_HOME home before falling back to $HOME/.config. Unfortunately, while we set XDG_CACHE_HOME, we do not set XDG_CONFIG_HOME.
This is a request to set that missing XDG environment in our images, so that things like this don't break anymore.
And for npm specifically, we should also set NPM_CONFIG_update_notifier=false.