npm WARN old lockfile The package-lock.json file was created with an old version of npm npm WARN old lockfile The package-lock.json file was created with an old version of npm docker docker

npm WARN old lockfile The package-lock.json file was created with an old version of npm


There are several ways to deal with this:

  1. Ignore it. It's just a warning, and all that's happening is npm is adding information to the package-lock.json file.

  2. Run npm ci with a newer version of npm in your development environment. It will give the warning and update the package-lock.json file. Commit that version to the repo/Docker image or whatever.

  3. Downgrade npm to an older version in production. Consider running npm version 6 as that is what ships with the current (as of this writing) LTS version of Node.js. In the case being asked about in this question, I imagine you can just leave out the RUN npm -g install npm@7.19.1 from the Dockerfile and instead use the version of npm that is installed with the Docker image (which in this case will almost certainly be npm@6 since that is what ships with Node.js 14.x).

  4. Probably not useful here, but for completeness, I'll mention that if you already have a version of npm installed but want to run one command with an older version of npm but otherwise keep the newer version, you can use npx (which ships with npm) to do that. Use the -p flag to specify the version of npm you want. For example, npx -p npm@6 npm ci would run npm ci with npm version 6 even if you have version 7 installed.


I am having the same problem as well after upgrading my npm version, it seems like a bug from npm 7.19.1, I'd suggest to downgrade to an older version.

You can check below for all the npm versionshttps://www.npmjs.com/package/npm?activeTab=versions

install the desired version with this command in the console, substitute "V" with your desired version:

 npm install -g npm@"V"


I had a similar problem but upgrading npm npm i -g npm on my machine before building the image solved it for me. You may still get the warn message but the image build process won't be halted.