[BUG] Get a package with optionnalDependencies from private registry. Get private package with `cpu` and `os` specified.
Is there an existing issue for this?
- [X] I have searched the existing issues
This issue exists in the latest npm version
- [X] I am using the latest npm
Current Behavior
I use a private Gitlab registry to publish my packages. When I install a package that has optionalDependencies, they do not get installed. If I have a private package that contains os and cpu fields, it gets installed even if I'm not on the right platform.
Expected Behavior
The behavior should be the same as usual, which means installing the optionalDependencies and/or, in the case of a package with cpu and os fields specified, installing or not installing it on the platform (Windows/Linux) according to the fields specified in the package.json.
Steps To Reproduce
Let's say I have the following private package, @foo/bar, which contains private optionalDependencies @foo/bar.linux-x64 and @foo/bar.win32-x64 :
@foo/bar
{
"name": "@foo/bar",
"version": "0.0.1",
"publishConfig": {
"@foo:registry": "https://private-gitlab-registry.com/"
},
"optionalDependencies": {
"@foo/bar.linux-x64": "^0.0.1",
"@foo/bar.win32-x64": "^0.0.1"
}
}
@foo/bar.linux-x64
{
"name": "@foo/bar.linux-x64",
"version": "0.0.1",
"publishConfig": {
"@foo:registry": "https://private-gitlab-registry.com/"
},
"os": [
"linux"
],
"cpu": [
"x64"
]
}
@foo/bar.win32-x64
{
"name": "@foo/bar.win32-x64",
"version": "0.0.1",
"publishConfig": {
"@foo:registry": "https://private-gitlab-registry.com/"
},
"os": [
"win32"
],
"cpu": [
"x64"
]
}
First point => If, in another project, I run npm i @foo/bar, @foo/bar installs correctly but the optionalDependencies do not. I don't get any info with --verbose, they simply are not GET.
Second point => If I install npm i @foo/bar.linux-x64 on a Windows platform, the package installs and I don't get any platform-related errors.
Environment
- npm: 10.7.0
- Node.js: 20.6.0
- OS Name: Windows x64
- npm config:
; "builtin" config from C:\Users\Boz\AppData\Roaming\npm\node_modules\npm\npmrc
prefix = "C:\\Users\\Boz\\AppData\\Roaming\\npm"
; "user" config from C:\Users\Boz\.npmrc
@foo:registry = "https://gitlab.com/api/v4/packages/npm/"
//gitlab.com/api/v4/packages/npm/:_authToken = (protected)
//registry.npmjs.org/:_authToken = (protected)
registry = "https://registry.npmjs.org/"
; "project" config from C:\foo\bar\.npmrc
package-lock = false
; node bin location = C:\Program Files\nodejs\node.exe
; node version = v20.6.0
; npm local prefix = C:\foo\bar
; npm version = 10.7.0
; cwd = C:\foo\bar
; HOME = C:\Users\Boz
; Run `npm config ls -l` to show all defaults.
; "publishConfig" from C:\foo\bar\package.json
; This set of config values will be used at publish-time.
@foo:registry = "https://private-registry.com/"