Skip to content

[BUG] npm commands can fail with ERR_INVALID_ARG_TYPE when normalizing manifests including a directories.bin fieldΒ #8722

@tubacoopa

Description

@tubacoopa

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

When installing a package whose registry-provided manifest includes a directories.bin field, but not a bin field, installation fails with the error:

npm error code ERR_INVALID_ARG_TYPE
npm error The "paths[0]" argument must be of type string. Received undefined

This appears to stem from @npmcli/[email protected] adding the 'bindir' step to normalization, creating a potential branch where the package path is expected to be defined. When fetching the manifest however, pacote instantiates a PackageJson in such a way that the path is not defined, which can result in the noted error when normalization occurs immediately afterward.

Because the npm public registry appears to calculate the effective bin field for packages only specifying directories.bin, this issue may be specific to users installing from self-hosted/alternative/mirror registries.

Expected Behavior

Installation should succeed for manifests including a directories.bin entry, but not a bin entry.

Steps To Reproduce

  1. Run npm install <package> for a package whose registry-provided manifest includes a directories.bin field, but not a bin field
    *(may require installing from a self-hosted/alternative/mirror registry)
  2. See error like:
0 verbose cli C:\Program Files\nodejs\node.exe C:\Users\tubacoopa\AppData\Roaming\npm\node_modules\npm\bin\npm-cli.js
1 info using [email protected]
2 info using [email protected]
3 silly config load:file:C:\Users\tubacoopa\AppData\Roaming\npm\node_modules\npm\npmrc
4 silly config load:file:C:\Users\tubacoopa\test\.npmrc
5 silly config load:file:C:\Users\tubacoopa\.npmrc
6 silly config load:file:C:\Users\tubacoopa\AppData\Roaming\npm\etc\npmrc
7 verbose title npm install sshpk
8 verbose argv "install" "sshpk"
9 verbose logfile logs-max:10 dir:C:\Users\tubacoopa\AppData\Local\npm-cache\_logs\2025-11-04T17_16_19_939Z-
10 verbose logfile C:\Users\tubacoopa\AppData\Local\npm-cache\_logs\2025-11-04T17_16_19_939Z-debug-0.log
11 silly logfile start cleaning logs, removing 1 files
12 silly packumentCache heap:4496293888 maxSize:1124073472 maxEntrySize:562036736
13 silly logfile done cleaning log files
14 silly idealTree buildDeps
15 silly fetch manifest sshpk@*
16 silly packumentCache full:(protected)/sshpk cache-miss
17 http fetch GET 200 (protected)/sshpk 1219ms (cache revalidated)
18 silly packumentCache full:(protected)/sshpk set size:6507 disposed:false
19 silly placeDep ROOT sshpk@ OK for:  want: *
20 verbose stack TypeError [ERR_INVALID_ARG_TYPE]: The "paths[0]" argument must be of type string. Received undefined
20 verbose stack     at Object.resolve (node:path:199:9)
20 verbose stack     at asyncSteps (C:\Users\tubacoopa\AppData\Roaming\npm\node_modules\npm\node_modules\@npmcli\package-json\lib\normalize.js:479:57)
20 verbose stack     at normalize (C:\Users\tubacoopa\AppData\Roaming\npm\node_modules\npm\node_modules\@npmcli\package-json\lib\normalize.js:605:9)
20 verbose stack     at PackageJson.normalize (C:\Users\tubacoopa\AppData\Roaming\npm\node_modules\npm\node_modules\@npmcli\package-json\lib\index.js:276:11)
20 verbose stack     at RegistryFetcher.manifest (C:\Users\tubacoopa\AppData\Roaming\npm\node_modules\npm\node_modules\pacote\lib\registry.js:134:9)
20 verbose stack     at async #fetchManifest (C:\Users\tubacoopa\AppData\Roaming\npm\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\build-ideal-tree.js:1227:20)
20 verbose stack     at async #nodeFromEdge (C:\Users\tubacoopa\AppData\Roaming\npm\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\build-ideal-tree.js:1065:19)
20 verbose stack     at async #buildDepStep (C:\Users\tubacoopa\AppData\Roaming\npm\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\build-ideal-tree.js:929:11)
20 verbose stack     at async Arborist.buildIdealTree (C:\Users\tubacoopa\AppData\Roaming\npm\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\build-ideal-tree.js:182:7)
20 verbose stack     at async Promise.all (index 1)
21 error code ERR_INVALID_ARG_TYPE
22 error The "paths[0]" argument must be of type string. Received undefined
23 silly unfinished npm timer reify 1762276580954
24 silly unfinished npm timer reify:loadTrees 1762276580956
25 verbose cwd C:\Users\tubacoopa\test
26 verbose os Windows_NT 10.0.26100
27 verbose node v24.11.0
28 verbose npm  v11.6.2
29 verbose exit 1
30 verbose code 1
31 error A complete log of this run can be found in: C:\Users\tubacoopa\AppData\Local\npm-cache\_logs\2025-11-04T17_16_19_939Z-debug-0.log

Environment

  • npm: 11.6.2
  • Node.js: 24.11.0
  • OS Name: Windows 11
  • System Model Name: Dell OptiPlex 7090
  • npm config:
; "builtin" config from C:\Users\tubacoopa\AppData\Roaming\npm\node_modules\npm\npmrc

prefix = "C:\\Users\\tubacoopa\\AppData\\Roaming\\npm"

; "user" config from C:\Users\tubacoopa\.npmrc

registry = "(protected)"

; node bin location = C:\Program Files\nodejs\node.exe
; node version = v24.11.0
; npm local prefix = C:\Users\tubacoopa\test
; npm version = 11.6.2
; cwd = C:\Users\tubacoopa\test
; HOME = C:\Users\tubacoopa
; Run `npm config ls -l` to show all defaults.

Metadata

Metadata

Assignees

Labels

Bugthing that needs fixingNeeds Triageneeds review for next steps

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions