There are several ways to deal with this:
-
Ignore it. It’s just a warning and does not affect the installation of modules.
-
Run
npm install --package-lock-only(with the newer version ofnpm) to regenerate apackage-lock.json. Commit the updated version ofpackage-lock.jsonto the repo/Docker image or whatever. -
Downgrade
npmto an older version in production. Consider runningnpmversion 6 as that is what ships with the current (as of this writing) Long Term Support (LTS) version of Node.js. In the case being asked about in this question, I imagine you can just leave out theRUN npm -g install npm@7.19.1from the Dockerfile and instead use the version ofnpmthat is installed with the Docker image (which in this case will almost certainly benpm@6since that is what ships with Node.js 14.x). -
If you already have a version of
npminstalled but want to run one command with an older version ofnpmbut otherwise keep the newer version, you can usenpx(which ships withnpm) to do that. For example,npx npm@6 ciwould runnpm ciwithnpmversion 6 even if you have version 7 installed.