Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fallback for missing packument.versions #91

Merged
merged 2 commits into from Jul 26, 2023
Merged

Conversation

chernodub
Copy link

@chernodub chernodub commented Jul 26, 2023

Object.keys will throw if nullish value is provided. I faced the error when tried to install deps from our internal registry. This caused the following error:

10300 verbose stack TypeError: Cannot convert undefined or null to object
10300 verbose stack     at Function.keys (<anonymous>)
10300 verbose stack     at module.exports (~/node/18.17.0/lib/node_modules/npm/node_modules/npm-pick-manifest/lib/index.js:213:22)
10300 verbose stack     at RegistryFetcher.manifest (~/node/18.17.0/lib/node_modules/npm/node_modules/pacote/lib/registry.js:119:22)
10300 verbose stack     at async Promise.all (index 12)
10300 verbose stack     at async #buildDepStep (~/node/18.17.0/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:1034:5)
10300 verbose stack     at async Arborist.buildIdealTree (~/node/18.17.0/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:196:7)
10300 verbose stack     at async Promise.all (index 1)
10300 verbose stack     at async Arborist.reify (~/node/18.17.0/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/reify.js:159:5)
10300 verbose stack     at async Install.exec (~/node/18.17.0/lib/node_modules/npm/lib/commands/install.js:147:5)
10300 verbose stack     at async module.exports (~/node/18.17.0/lib/node_modules/npm/lib/cli.js:89:5)

When I added the fallback, the error rendered fine and I was able to figure out what caused the problem:

Error example after the fix:

npm verb stack internal-package: No matching version found for internal-package@1.3.2.
npm verb stack     at module.exports (~/18.17.0/lib/node_modules/npm/node_modules/npm-pick-manifest/lib/index.js:209:23)
npm verb stack     at RegistryFetcher.manifest (~/18.17.0/lib/node_modules/npm/node_modules/pacote/lib/registry.js:119:22)
npm verb stack     at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
npm verb stack     at async Promise.all (index 12)
npm verb stack     at async #buildDepStep (~/18.17.0/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:1034:5)
npm verb stack     at async Arborist.buildIdealTree (~/18.17.0/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:196:7)
npm verb stack     at async Promise.all (index 1)
npm verb stack     at async Arborist.reify (~/18.17.0/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/reify.js:159:5)
npm verb stack     at async Install.exec (~/18.17.0/lib/node_modules/npm/lib/commands/install.js:147:5)
npm verb stack     at async module.exports (~/18.17.0/lib/node_modules/npm/lib/cli.js:89:5)
npm verb cwd /Users/user/internal-app
npm verb Darwin 21.6.0
npm verb node v18.17.0
npm verb npm  v9.6.7
npm ERR! code ETARGET
npm ERR! notarget No matching version found for internal-package@1.3.2.
npm ERR! notarget In most cases you or one of your dependencies are requesting
npm ERR! notarget a package version that doesn't exist.
npm verb exit 1

Closes #79

@chernodub chernodub requested a review from a team as a code owner July 26, 2023 17:50
@wraithgar
Copy link
Member

Seems pretty straightforward, but would need a test.

@chernodub
Copy link
Author

@wraithgar thanks for reviewing this! I added a test for this.

@wraithgar wraithgar changed the title Add fallback for packument.versions fix: fallback for missing packument.versions Jul 26, 2023
@wraithgar wraithgar merged commit 66c3754 into npm:main Jul 26, 2023
23 of 24 checks passed
@github-actions github-actions bot mentioned this pull request Jul 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] Cannot convert undefined or null to object
2 participants