Skip to content

[BUG] npm outdated fails to parse aliases #2800

Description

@ruyadorno

Current Behavior:

Running npm outdated on a folder that contains a package.json using aliases (e.g: npm install <alias>@npm:<name>), see: https://docs.npmjs.com/cli/v7/commands/npm-install

Expected Behavior:

npm outdated should work.

Steps To Reproduce:

Given a package.json using aliases:

commit 8bda27aed14024a3d15f1802c04c13ddda706e02 (HEAD -> main)
Author: Ruy Adorno <ruyadorno@hotmail.com>
Date:   Mon Mar 1 10:54:40 2021 -0500

    Initial commit

diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..3c3629e
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+node_modules
diff --git a/package-lock.json b/package-lock.json
new file mode 100644
index 0000000..733811a
--- /dev/null
+++ b/package-lock.json
@@ -0,0 +1,27 @@
+{
+  "name": "test-outdated-alias",
+  "version": "1.0.0",
+  "lockfileVersion": 2,
+  "requires": true,
+  "packages": {
+    "": {
+      "version": "1.0.0",
+      "dependencies": {
+        "foo": "npm:abbrev@^1.1.1"
+      }
+    },
+    "node_modules/foo": {
+      "name": "abbrev",
+      "version": "1.1.1",
+      "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz",
+      "integrity": "sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q=="
+    }
+  },
+  "dependencies": {
+    "foo": {
+      "version": "npm:abbrev@1.1.1",
+      "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz",
+      "integrity": "sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q=="
+    }
+  }
+}
diff --git a/package.json b/package.json
new file mode 100644
index 0000000..b10a0f9
--- /dev/null
+++ b/package.json
@@ -0,0 +1,7 @@
+{
+  "name": "test-outdated-alias",
+  "version": "1.0.0",
+  "dependencies": {
+    "foo": "npm:abbrev@^1.1.1"
+  }
+}

Run outdated

$ npm outdated --loglevel=silly
npm verb cli [
npm verb cli   '/Users/ruyadorno/Documents/ruyadorno/nodejs/out/Release/node',
npm verb cli   '/Users/ruyadorno/Documents/workspace/cli/main',
npm verb cli   'outdated',
npm verb cli   '--loglevel=silly'
npm verb cli ]
npm info using npm@7.6.0
npm info using node@v16.0.0-pre
npm timing config:load:defaults Completed in 1ms
npm timing config:load:file:/Users/ruyadorno/Documents/workspace/cli/main/npmrc Completed in 0ms
npm timing config:load:builtin Completed in 0ms
npm timing config:load:cli Completed in 2ms
npm timing config:load:env Completed in 0ms
npm timing config:load:file:/Users/ruyadorno/tmp/test-outdated-alias/.npmrc Completed in 0ms
npm timing config:load:project Completed in 0ms
npm timing config:load:file:/Users/ruyadorno/.npmrc Completed in 1ms
npm timing config:load:user Completed in 1ms
npm timing config:load:file:/Users/ruyadorno/npm-prefix/etc/npmrc Completed in 0ms
npm timing config:load:global Completed in 1ms
npm timing config:load:cafile Completed in 0ms
npm timing config:load:validate Completed in 1ms
npm timing config:load:setUserAgent Completed in 0ms
npm timing config:load:setEnvs Completed in 1ms
npm timing config:load Completed in 7ms
npm verb npm-session f9afbefed03f194d
npm timing npm:load Completed in 16ms
npm timing arborist:ctor Completed in 1ms
npm timing arborist:ctor Completed in 1ms
npm http fetch GET 304 https://registry.npmjs.org/foo 548ms (from cache)
npm timing command:outdated Completed in 569ms
npm verb stack Error: Only tag, version, and range are supported
npm verb stack     at pickManifest (/Users/ruyadorno/Documents/workspace/cli/main/node_modules/npm-pick-manifest/index.js:92:11)
npm verb stack     at module.exports (/Users/ruyadorno/Documents/workspace/cli/main/node_modules/npm-pick-manifest/index.js:186:18)
npm verb stack     at getOutdatedInfo (/Users/ruyadorno/Documents/workspace/cli/main/lib/outdated.js:148:22)
npm verb stack     at processTicksAndRejections (node:internal/process/task_queues:94:5)
npm verb stack     at async Promise.all (index 0)
npm verb stack     at async outdated_ (/Users/ruyadorno/Documents/workspace/cli/main/lib/outdated.js:200:3)
npm verb stack     at async outdated (/Users/ruyadorno/Documents/workspace/cli/main/lib/outdated.js:40:16)
npm verb cwd /Users/ruyadorno/tmp/test-outdated-alias
npm verb Darwin 19.6.0
npm verb argv "/Users/ruyadorno/Documents/ruyadorno/nodejs/out/Release/node" "/Users/ruyadorno/Documents/workspace/cli/main" "outdated" "--loglevel=silly"
npm verb node v16.0.0-pre
npm verb npm  v7.6.0
npm ERR! Only tag, version, and range are supported
npm verb exit 1
npm timing npm Completed in 754ms
npm verb code 1

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Bugthing that needs fixingPriority 2secondary priority issueRelease 7.xwork is associated with a specific npm 7 release

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions