Issue 1:
Is there an existing issue for this?

I have searched the existing issues

Current Behavior

Running npm install does not install correct versions of dependencies in place of the existing old versions if the lockfile includes a version change in addition to dependency version upgrades. See reproduction for more details.

Related or possibly a duplicate of: #3057, #3196.

Expected Behavior

After running npm install, the dependencies in node_modules should match the lockfile contents.

Steps To Reproduce

git clone git@github.com:denis-sokolov/npm-6-to-7-old-dependency-reproduction.git && cd npm-6-to-7-old-dependency-reproduction

git checkout base

npm6 install (I used 6.14.9)

git checkout master

npm7 install (I used 7.11.2)

cat node_modules/\@types/react-select/package.json | grep 'version":'

Observed:

"version": "3.0.22"

Expected:

"version": "4.0.15",

Workaround: rm -rf node_modules && npm install.

If reproduction fails, please see the with-node-modules branch that has node_modules included in the repository.

Environment

OS: macOS 11.3.1

Node: 14.14.0

npm: 7.11.2, also reproduced with 7.13.0

Issue 2:
Is there an existing issue for this?

I have searched the existing issues

This issue exists in the latest npm version

I am using the latest npm

Current Behavior

It gives me this ERROR:

npm ERR! Exit handler never called!

npm ERR! This is an error with npm itself. Please report this error at:

npm ERR! https://github.com/npm/cli/issues

and in other versions this:

npm ERR! code ECONNREFUSED

npm ERR! syscall connect

npm ERR! errno ECONNREFUSED

npm ERR! FetchError: request to https://registry.npmjs.org/@ungap/promise-all-settled/-/promise-all-settled-1.1.2.tgz failed, reason: connect ECONNREFUSED 2606:4700::6810:1823:443

npm ERR! at ClientRequest. (C:\Program Files\nodejs\node_modules\npm\node_modules\minipass-fetch\lib\index.js:130:14)

npm ERR! at ClientRequest.emit (node:events:513:28)

npm ERR! at TLSSocket.socketErrorListener (node:_http_client:502:9)

npm ERR! at TLSSocket.emit (node:events:525:35)

npm ERR! at emitErrorNT (node:internal/streams/destroy:151:8)

npm ERR! at emitErrorCloseNT (node:internal/streams/destroy:116:3)

npm ERR! at process.processTicksAndRejections (node:internal/process/task_queues:82:21)

npm ERR! FetchError: request to https://registry.npmjs.org/@ungap/promise-all-settled/-/promise-all-settled-1.1.2.tgz failed, reason: connect ECONNREFUSED 2606:4700::6810:1823:443

npm ERR! at ClientRequest. (C:\Program Files\nodejs\node_modules\npm\node_modules\minipass-fetch\lib\index.js:130:14)

npm ERR! at ClientRequest.emit (node:events:513:28)

npm ERR! at TLSSocket.socketErrorListener (node:_http_client:502:9)

npm ERR! at TLSSocket.emit (node:events:525:35)

npm ERR! at emitErrorNT (node:internal/streams/destroy:151:8)

npm ERR! at emitErrorCloseNT (node:internal/streams/destroy:116:3)

npm ERR! at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {

npm ERR! code: 'ECONNREFUSED',

npm ERR! errno: 'ECONNREFUSED',

npm ERR! syscall: 'connect',

npm ERR! address: '2606:4700::6810:1823',

npm ERR! port: 443,

npm ERR! type: 'system'

npm ERR! }

npm ERR!

npm ERR! If you are behind a proxy, please make sure that the

npm ERR! 'proxy' config is set properly. See: 'npm help config'

Expected Behavior

it should install all dependencies from this project

Steps To Reproduce

clone vscode extension sample from this git repository: https://github.com/microsoft/vscode-extension-samples

open cmd in vscode-extension-samples\lsp-sample

run: npm install

Environment

npm: 9.6.4

Node.js: 20.0.0

OS Name: Windows 11

System Model Name:

npm config:

{

"json": true,

"prefix": "C:\Users\helmu\AppData\Roaming\npm",

"access": null,

"all": false,

"allow-same-version": false,

"also": null,

"audit": true,

"audit-level": null,

"auth-type": "web",

"before": null,

"bin-links": true,

"browser": null,

"ca": null,

"cache": "C:\Users\helmu\AppData\Local\npm-cache",

"cache-max": null,

"cache-min": 0,

"cafile": null,

"call": "",

"cert": null,

"ci-name": null,

"cidr": null,

"color": true,

"commit-hooks": true,

"depth": null,

"description": true,

"dev": false,

"diff": [],

"diff-ignore-all-space": false,

"diff-name-only": false,

"diff-no-prefix": false,

"diff-dst-prefix": "b/",

"diff-src-prefix": "a/",

"diff-text": false,

"diff-unified": 3,

"dry-run": false,

"editor": "C:\WINDOWS\notepad.exe",

"engine-strict": false,

"fetch-retries": 2,

"fetch-retry-factor": 10,

"fetch-retry-maxtimeout": 60000,

"fetch-retry-mintimeout": 10000,

"fetch-timeout": 300000,

"force": false,

"foreground-scripts": false,

"format-package-lock": true,

"fund": true,

"git": "git",

"git-tag-version": true,

"global": false,

"globalconfig": "C:\Users\helmu\AppData\Roaming\npm\etc\npmrc",

"global-style": false,

"heading": "npm",

"https-proxy": null,

"if-present": false,

"ignore-scripts": false,

"include": [],

"include-staged": false,

"include-workspace-root": false,

"init-author-email": "",

"init-author-name": "",

"init-author-url": "",

"init-license": "ISC",

"init-module": "C:\Users\helmu\.npm-init.js",

"init-version": "1.0.0",

"init.author.email": "",

"init.author.name": "",

"init.author.url": "",

"init.license": "ISC",

"init.module": "C:\Users\helmu\.npm-init.js",

"init.version": "1.0.0",

"install-links": false,

"install-strategy": "hoisted",

"key": null,

"legacy-bundling": false,

"legacy-peer-deps": false,

"link": false,

"local-address": null,

"location": "user",

"lockfile-version": null,

"loglevel": "notice",

"logs-dir": null,

"logs-max": 10,

"long": false,

"maxsockets": 15,

"message": "%s",

"node-options": null,

"noproxy": [

""

],

"offline": false,

"omit": [],

"omit-lockfile-registry-resolved": false,

"only": null,

"optional": null,

"otp": null,

"package": [],

"package-lock": true,

"package-lock-only": false,

"pack-destination": ".",

"parseable": false,

"prefer-offline": false,

"prefer-online": false,

"preid": "",

"production": null,

"progress": true,

"provenance": false,

"proxy": null,

"read-only": false,

"rebuild-bundle": true,

"registry": "https://registry.npmjs.org/",

"replace-registry-host": "npmjs",

"save": true,

"save-bundle": false,

"save-dev": false,

"save-exact": false,

"save-optional": false,

"save-peer": false,

"save-prefix": "^",

"save-prod": false,

"scope": "",

"script-shell": null,

"searchexclude": "",

"searchlimit": 20,

"searchopts": "",

"searchstaleness": 900,

"shell": "C:\WINDOWS\system32\cmd.exe",

"shrinkwrap": true,

"sign-git-commit": false,

"sign-git-tag": false,

"strict-peer-deps": false,

"strict-ssl": true,

"tag": "latest",

"tag-version-prefix": "v",

"timing": false,

"tmp": "C:\Users\helmu\AppData\Local\Temp",

"umask": 0,

"unicode": true,

"update-notifier": true,

"usage": false,

"user-agent": "npm/{npm-version} node/{node-version} {platform} {arch} workspaces/{workspaces} {ci}",

"userconfig": "C:\Users\helmu\.npmrc",

"version": false,

"versions": false,

"viewer": "browser",

"which": null,

"workspace": [],

"workspaces": null,

"workspaces-update": true,

"yes": null,

"metrics-registry": "https://registry.npmjs.org/"

}