From 76b445a7ba9e0b650a60c5684caaad1bbcd8adba Mon Sep 17 00:00:00 2001 From: Gar Date: Fri, 7 May 2021 09:41:55 -0700 Subject: [PATCH] fix(view): fix non-registry specs This was working by coincidence in 7.7.6 and before, and broken in the 7.8.0 refactor. Before, it would see there was no "name" in the spec, and then read your local package.json, and from that get a `latest` tag. So, if you didn't have a package.json in your CWD it would fail with an ENOENT trying to read it. This fixes it for real, so that if you aren't asking for info from a registry spec, it goes ahead and looks for the `latest` tag (or whatever tag you have configured as your default). --- lib/view.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/view.js b/lib/view.js index 91b32e2fd38fa..e7e404e2ebb86 100644 --- a/lib/view.js +++ b/lib/view.js @@ -202,7 +202,10 @@ class View extends BaseCommand { const spec = npa(pkg) // get the data about this package - let version = spec.rawSpec || this.npm.config.get('tag') + let version = this.npm.config.get('tag') + // rawSpec is only a version if this is a registry spec + if (spec.type === 'registry' && spec.rawSpec) + version = spec.rawSpec const pckmnt = await packument(spec, opts)