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 does not affect the installation of modules.

  2. Run npm install --package-lock-only (with the newer version of npm) to regenerate a package-lock.json. Commit the updated version of package-lock.json 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) Long Term Support (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. 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. For example, npx npm@6 ci would run npm ci with npm version 6 even if you have version 7 installed.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)