Issue 1:
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

I have a mono-repo configuration with the following structure:

- packages
|--- app
|--- proxy
|--- types

Both proxy & app depends on @nugit/types (this is not the package in packages/types folder).

The packages @nugit/types is installed twice in packages/app & packages/proxy.

Expected Behavior

Package to be installed once in root node_modules.

Steps To Reproduce

This is a private repository, with private packages but here is an extract of my package-lock.json

{
"name": "nugit-app",
"version": "0.1.0",
"lockfileVersion": 2,
"requires": true,
"packages": {
"packages/app": {
"name": "nugit-app-fe",
"version": "0.1.0",
"dependencies": {
"@nugit/env-service": "^3.0.0",
"@nugit/time-service": "^3.0.0",
"@nugit/types": "^3.0.0"
},
"devDependencies": {},
"engines": {
"node": ">=14.18.0"
}
},
"packages/app/node_modules/@nugit/types": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/@nugit/types/-/types-3.0.0.tgz",
"integrity": "sha512-HJORiTzwyJ+KjaT/PO2Cb9YBy13Uj5K6T3InN5t4XYYmXhxXdF5PjLeWf+aMc724fPIz9bFbw9HXeiVTw2YEaA==",
"dependencies": {
"@babel/runtime": "^7.17.7",
"core-js": "^3.21.0"
},
"engines": {
"node": ">=14.18.0"
},
"peerDependencies": {
"react": "^16.3.0 || ^17.0.2"
}
},
"packages/proxy": {
"name": "nugit-app-proxy",
"version": "0.1.0",
"dependencies": {
"@nugit/env-service": "^3.0.0",
"@nugit/logger-service": "^3.0.0",
"@nugit/types": "^3.0.0"
},
"devDependencies": {
},
"engines": {
"node": ">=14.18.0"
}
},
"packages/proxy/node_modules/@nugit/types": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/@nugit/types/-/types-3.0.0.tgz",
"integrity": "sha512-HJORiTzwyJ+KjaT/PO2Cb9YBy13Uj5K6T3InN5t4XYYmXhxXdF5PjLeWf+aMc724fPIz9bFbw9HXeiVTw2YEaA==",
"dependencies": {
"@babel/runtime": "^7.17.7",
"core-js": "^3.21.0"
},
"engines": {
"node": ">=14.18.0"
},
"peerDependencies": {
"react": "^16.3.0 || ^17.0.2"
}
},
"dependencies": {
"nugit-app-fe": {
"@nugit/types": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/@nugit/types/-/types-3.0.0.tgz",
"integrity": "sha512-HJORiTzwyJ+KjaT/PO2Cb9YBy13Uj5K6T3InN5t4XYYmXhxXdF5PjLeWf+aMc724fPIz9bFbw9HXeiVTw2YEaA==",
"requires": {
"@babel/runtime": "^7.17.7",
"core-js": "^3.21.0"
}
}
},
"nugit-app-proxy": {
"@nugit/types": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/@nugit/types/-/types-3.0.0.tgz",
"integrity": "sha512-HJORiTzwyJ+KjaT/PO2Cb9YBy13Uj5K6T3InN5t4XYYmXhxXdF5PjLeWf+aMc724fPIz9bFbw9HXeiVTw2YEaA==",
"requires": {
"@babel/runtime": "^7.17.7",
"core-js": "^3.21.0"
}
}
}
}
}
}

Environment

npm: 8.5.0

Node.js: v16.14.1

OS Name: macOs Montery (12.0.1) - Apple M1

System Model Name: Macbook Pro

npm config:

; "user" config from /Users/moroine/.npmrc

; //registry.npmjs.org/:_authToken = (protected) ; overridden by project

; "project" config from /Users/moroine/Workspace/Nugit/nugit-app/.npmrc

//registry.npmjs.org/:_authToken = (protected)

; node bin location = /usr/local/bin/node
; cwd = /Users/moroine/Workspace/Nugit/nugit-app
; HOME = /Users/moroine
; Run `npm config ls -l` to show all defaults.

Issue 2:
Is there an existing issue for this?

I have searched the existing issues

Current Behavior

See this demo repository: https://github.com/nsams/npm-workspace-issue

when running npm install @mdx-js/react package is installed twice:

./packages/admin-stories/node_modules/@storybook/addon-docs/node_modules/@mdx-js/react
./node_modules/@mdx-js/react

Expected Behavior

dependency should be installed only once

Steps To Reproduce

git clone https://github.com/nsams/npm-workspace-issue
cd npm-workspace-issue
npm install
find | grep @mdx-js/react

Environment

OS: Ubuntu 18.04

Node: 14.17.1

npm: 7.19.0