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

[BUG] npm outdated fails to parse aliases #2800

Closed
ruyadorno opened this issue Mar 1, 2021 · 13 comments
Closed

[BUG] npm outdated fails to parse aliases #2800

ruyadorno opened this issue Mar 1, 2021 · 13 comments
Labels
Bug thing that needs fixing Priority 2 secondary priority issue Release 7.x work is associated with a specific npm 7 release

Comments

@ruyadorno
Copy link
Contributor

ruyadorno commented Mar 1, 2021

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 <[email protected]>
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:[email protected]",
+      "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 [email protected]
npm info using [email protected]
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
@ruyadorno ruyadorno added Release 7.x work is associated with a specific npm 7 release Bug thing that needs fixing Needs Triage needs review for next steps Priority 2 secondary priority issue and removed Needs Triage needs review for next steps labels Mar 1, 2021
@ChrisCrossCrash
Copy link

ChrisCrossCrash commented Mar 3, 2021

I am also getting this issue. For me the issue was caused by this dependency:

"gsap": "npm:@gsap/shockingly@^3.6.0",

It needs to be installed with an alias to take advantage of the paid features of the shockingly version.

This is in a public repo of mine.

Additional Info

Windows 10
npm 7.6.0
node v12.18.4
git version 2.30.1.windows.1

C:\Users\Chris\Sync\PythonProjects\chriskumm.com\chriskumm.com_gatsby\src>npm outdated --all
npm ERR! Only tag, version, and range are supported

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Chris\AppData\Local\npm-cache\_logs\2021-03-03T10_34_30_128Z-debug.log

2021-03-03T10_34_30_128Z-debug.log:

0 verbose cli [
0 verbose cli   'C:\\Program Files\\nodejs\\node.exe',
0 verbose cli   'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
0 verbose cli   'outdated',
0 verbose cli   '--all'
0 verbose cli ]
1 info using [email protected]
2 info using [email protected]
3 timing config:load:defaults Completed in 1ms
4 timing config:load:file:C:\Program Files\nodejs\node_modules\npm\npmrc Completed in 2ms
5 timing config:load:builtin Completed in 2ms
6 timing config:load:cli Completed in 1ms
7 timing config:load:env Completed in 1ms
8 timing config:load:file:C:\Users\Chris\Sync\PythonProjects\chriskumm.com\chriskumm.com_gatsby\.npmrc Completed in 0ms
9 timing config:load:project Completed in 1ms
10 timing config:load:file:C:\Users\Chris\.npmrc Completed in 1ms
11 timing config:load:user Completed in 1ms
12 timing config:load:file:C:\Users\Chris\AppData\Roaming\npm\etc\npmrc Completed in 0ms
13 timing config:load:global Completed in 0ms
14 timing config:load:cafile Completed in 0ms
15 timing config:load:validate Completed in 1ms
16 timing config:load:setUserAgent Completed in 1ms
17 timing config:load:setEnvs Completed in 0ms
18 timing config:load Completed in 9ms
19 verbose npm-session 78ae70b18b9b75fe
20 timing npm:load Completed in 19ms
21 timing arborist:ctor Completed in 0ms
22 timing arborist:ctor Completed in 0ms
23 http fetch GET 304 https://registry.npmjs.org/gatsby-plugin-postcss 10885ms (from cache)
24 http fetch GET 304 https://registry.npmjs.org/autoprefixer 10900ms (from cache)
25 http fetch GET 304 https://registry.npmjs.org/gatsby-image 10898ms (from cache)
26 http fetch GET 304 https://registry.npmjs.org/dotenv 10916ms (from cache)
27 http fetch GET 304 https://registry.npmjs.org/gatsby-plugin-robots-txt 10907ms (from cache)
28 http fetch GET 304 https://registry.npmjs.org/gatsby-plugin-sharp 10918ms (from cache)
29 http fetch GET 304 https://registry.npmjs.org/gatsby-background-image 10949ms (from cache)
30 http fetch GET 304 https://registry.npmjs.org/gatsby-plugin-remove-serviceworker 10976ms (from cache)
31 http fetch GET 304 https://registry.npmjs.org/prettier 11001ms (from cache)
32 http fetch GET 304 https://registry.npmjs.org/gsap 11019ms (from cache)
33 timing command:outdated Completed in 12241ms
34 verbose stack Error: Only tag, version, and range are supported
34 verbose stack     at pickManifest (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-pick-manifest\index.js:92:11)
34 verbose stack     at module.exports (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-pick-manifest\index.js:186:18)
34 verbose stack     at getOutdatedInfo (C:\Program Files\nodejs\node_modules\npm\lib\outdated.js:148:22)
34 verbose stack     at async Promise.all (index 16)
34 verbose stack     at async outdated_ (C:\Program Files\nodejs\node_modules\npm\lib\outdated.js:200:3)
34 verbose stack     at async outdated (C:\Program Files\nodejs\node_modules\npm\lib\outdated.js:40:16)
35 verbose cwd C:\Users\Chris\Sync\PythonProjects\chriskumm.com\chriskumm.com_gatsby\src
36 verbose Windows_NT 10.0.19042
37 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "outdated" "--all"
38 verbose node v12.18.4
39 verbose npm  v7.6.0
40 error Only tag, version, and range are supported
41 verbose exit 1

ChrisCrossCrash added a commit to ChrisCrossCrash/chriskumm.com_gatsby that referenced this issue Mar 3, 2021
- Several major dependency updates (see changes in `package.json`)
- `shockingly` version of `gsap` was causing issues, as it uses an alias, which causes issues when using `npm update`. The `shockingly` version wasn't needed anyways. See this issue: npm/cli#2800
- Ran codemod: `npx gatsby-codemods gatsby-plugin-image` (see: https://www.npmjs.com/package/gatsby-plugin-image#migrating )
- Uninstalled `prettier` as it was not used

TODO:
- Fix the depreciation warning caused by `gatsby-transformer-sharp`
- Have a look over the image queries to see if they can be improved.
@zackdotcomputer
Copy link

This also crops up with Tailwind's instructions for using it with Create-React-App, which are based on an alias as well: https://tailwindcss.com/docs/guides/create-react-app

npm install -D tailwindcss@npm:@tailwindcss/postcss7-compat

@nonameolsson
Copy link

This happens to me as well. I had to change from using the official eslint-plugin-prettier due to a bug.

I have temporarily switched to another version in an open PR by changing to this line: "eslint-plugin-prettier": "npm:@rxts/eslint-plugin-prettier@^3.4.0-1",.

This makes npm outdated fail with this error:

Error while gathering outdated dependencies:

stack Error: Command failed: npm outdated --json --long --save false
stack npm ERR! Only tag, version, and range are supported
stack {
stack   "error": {
stack     "code": null,
stack     "summary": "Only tag, version, and range are supported",
stack     "detail": ""
stack   }
stack }
stack 
stack npm ERR! A complete log of this run can be found in:
stack npm ERR!     /Users/andreasolsson/.npm/_logs/2021-03-25T08_18_12_288Z-debug.log
stack 
stack     at ChildProcess.exithandler (node:child_process:333:12)
stack     at ChildProcess.emit (node:events:376:20)
stack     at maybeClose (node:internal/child_process:1063:16)
stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:295:5)
message Command failed: npm outdated --json --long --save false
message npm ERR! Only tag, version, and range are supported
message {
message   "error": {
message     "code": null,
message     "summary": "Only tag, version, and range are supported",
message     "detail": ""
message   }
message }
message 
message npm ERR! A complete log of this run can be found in:
message npm ERR!     /Users/andreasolsson/.npm/_logs/2021-03-25T08_18_12_288Z-debug.log
message 
killed false
code 1
signal null
cmd npm outdated --json --long --save false

This is a pretty bad issue, since we run npm outdated as part of our CI. We have to remove that step from our CI now.

@Isaac-Tait
Copy link

Isaac-Tait commented Apr 15, 2021

I was having this issue with my Gatsby build. I found this issue, specifically this comment which helped me solve.

Initially when I had updated TailwindCSS to v.2 I had a pesky error, and the work around was to install a PostCSS7 compatibility build (see this doc).

I ran

npm uninstall tailwindcss @tailwindcss/postcss7-compat
npm install -D tailwindcss@latest postcss@latest autoprefixer@latest

which then allowed me to run npm outdated without returning the error npm ERR! Only tag, version, and range are supported.

The above removed the following code from my package.json file, which for some reason was triggering the error
"tailwindcss": "npm:@tailwindcss/postcss7-compat@^2.0.3", Now I can continue with the update of Gatsby to v3+

@StanislavKharchenko
Copy link

Any updates/estimation for this issue?

pastelmind added a commit to pastelmind/100familiars that referenced this issue Jun 14, 2021
Run `npm install` with NPM 7 to update `package-lock.json` format to v2.

NPM v7 has a bug with aliased packages when running `npm outdated`. To
avoid this, install `kolmafia-types` without aliasing, and update
TypeScript's config to resolve `kolmafia` to `kolmafia-types`.

Also, update `kolmafia-types` to 0.1.1.

- Description of the NPM v7 bug: npm/cli#2800
- Description of the workaround:
  https://github.com/pastelmind/kolmafia-types/tree/v0.1.1#method-2-use-a-custom-path-to-resolve-kolmafia
pastelmind added a commit to pastelmind/100familiars that referenced this issue Jun 14, 2021
Run `npm install` with NPM 7 to update `package-lock.json` format to v2.

NPM v7 has a bug with aliased packages when running `npm outdated`. To
avoid this, install `kolmafia-types` without aliasing, and update
TypeScript's config to resolve `kolmafia` to `kolmafia-types`.

Also, update `kolmafia-types` to 0.1.1.

- Description of the NPM v7 bug: npm/cli#2800
- Description of the workaround:
  https://github.com/pastelmind/kolmafia-types/tree/v0.1.1#method-2-use-a-custom-path-to-resolve-kolmafia
pastelmind added a commit to Loathing-Associates-Scripting-Society/display3 that referenced this issue Jun 14, 2021
Due to a bug in NPM v7, `npm outdated` fails when kolmafia-types is
aliased. To work around this, we install `kolmafia-types` by its name,
and TypeScript's `compilerOptions.paths` field is used to resolve
`kolmafia` to `kolmafia-types`.

We also install:

- kolmafia-types 0.1.1 (updated)
- tsconfig-paths which is needed to run tests with Jasmine + ts-node

See also:

- GitHub issue for the NPM v7 bug:
  npm/cli#2800
- Description of the workaround:
  https://github.com/pastelmind/kolmafia-types/tree/v0.1.1#method-2-use-a-custom-path-to-resolve-kolmafia
pastelmind added a commit to pastelmind/kolmafia-util that referenced this issue Jul 20, 2021
NPM v7 currently has a bug that causes `npm outdated` to fail when
`package.json` contains an aliased dependency. To work around this, we
use the `compilerOptions.paths` field in `tsconfig.json` to resolve
`kolmafia` to `kolmafia-types`.

See related bug report: npm/cli#2800
@daviddelusenet
Copy link

This is a pretty big bug, surprised it takes so long for it to be fixed

@kolchurinvv
Copy link

Just ran into the same issue trying to to migrate to Nuxt3, granted it came out pretty much this week.

OS: macOS Big Sur 11.6 (20G165)
npm: 8.0.0
node: v14.18.1

package.json

  "devDependencies": {
    "@babel/plugin-proposal-optional-chaining": "^7.12.7",
    "@nuxt/bridge": "npm:@nuxt/bridge-edge@^3.0.0-27235989.d52b1e8",
      ...
     }
➜ npm outdated
npm ERR! Only tag, version, and range are supported

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/vladimir/.npm/_logs/2021-10-14T11_20_08_839Z-debug.log

Log file content:

0 verbose cli [
0 verbose cli   '/Users/vladimir/.nvm/versions/node/v14.18.1/bin/node',
0 verbose cli   '/Users/vladimir/.nvm/versions/node/v14.18.1/bin/npm',
0 verbose cli   'outdated'
0 verbose cli ]
1 info using [email protected]
2 info using [email protected]
3 timing npm:load:whichnode Completed in 0ms
4 timing config:load:defaults Completed in 2ms
5 timing config:load:file:/Users/vladimir/.nvm/versions/node/v14.18.1/lib/node_modules/npm/npmrc Completed in 13ms
6 timing config:load:builtin Completed in 13ms
7 timing config:load:cli Completed in 2ms
8 timing config:load:env Completed in 0ms
9 timing config:load:file:/Users/vladimir/Dev_Projects/Proxify/Spixler/spixler-india/domains/indiagamblers.com/.npmrc Completed in 0ms
10 timing config:load:project Completed in 1ms
11 timing config:load:file:/Users/vladimir/.npmrc Completed in 1ms
12 timing config:load:user Completed in 1ms
13 timing config:load:file:/Users/vladimir/.nvm/versions/node/v14.18.1/etc/npmrc Completed in 1ms
14 timing config:load:global Completed in 1ms
15 timing config:load:validate Completed in 0ms
16 timing config:load:credentials Completed in 1ms
17 timing config:load:setEnvs Completed in 1ms
18 timing config:load Completed in 22ms
19 timing npm:load:configload Completed in 22ms
20 timing npm:load:setTitle Completed in 24ms
21 timing npm:load:setupLog Completed in 0ms
22 timing config:load:flatten Completed in 3ms
23 timing npm:load:cleanupLog Completed in 3ms
24 timing npm:load:configScope Completed in 0ms
25 timing npm:load:projectScope Completed in 1ms
26 timing npm:load Completed in 54ms
27 timing arborist:ctor Completed in 1ms
28 timing arborist:ctor Completed in 0ms
29 timing command:outdated Completed in 7645ms
30 verbose stack Error: Only tag, version, and range are supported
30 verbose stack     at pickManifest (/Users/vladimir/.nvm/versions/node/v14.18.1/lib/node_modules/npm/node_modules/npm-pick-manifest/index.js:93:11)
30 verbose stack     at module.exports (/Users/vladimir/.nvm/versions/node/v14.18.1/lib/node_modules/npm/node_modules/npm-pick-manifest/index.js:187:16)
30 verbose stack     at Outdated.getOutdatedInfo (/Users/vladimir/.nvm/versions/node/v14.18.1/lib/node_modules/npm/lib/outdated.js:228:22)
30 verbose stack     at async Promise.all (index 30)
30 verbose stack     at async Outdated.outdated (/Users/vladimir/.nvm/versions/node/v14.18.1/lib/node_modules/npm/lib/outdated.js:84:5)
31 verbose cwd /Users/vladimir/Dev_Projects/Proxify/Spixler/spixler-india/domains/indiagamblers.com
32 verbose Darwin 20.6.0
33 verbose argv "/Users/vladimir/.nvm/versions/node/v14.18.1/bin/node" "/Users/vladimir/.nvm/versions/node/v14.18.1/bin/npm" "outdated"
34 verbose node v14.18.1
35 verbose npm  v8.0.0
36 error Only tag, version, and range are supported
37 verbose exit 1

@benknight
Copy link

I've been having to work around this issue for like a year now. Looking forward to a solution.

@panva
Copy link

panva commented Nov 12, 2021

This issue is present in v7.x as well as v8.x.

@IamLizu
Copy link

IamLizu commented Nov 19, 2021

The above removed the following code from my package.json file, which for some reason was triggering the error "tailwindcss": "npm:@tailwindcss/postcss7-compat@^2.0.3", Now I can continue with the update of Gatsby to v3+

For my case, I had to switch back to the compat version of postcss after updating outdated packages.

Eagerly waiting for a fix.

@jhildenbiddle
Copy link

Also experiencing this issue with docsify.js. Running npm outdated fails due to the following dependencies in package.json:

https://github.com/docsifyjs/docsify/blob/e424a9d2257fd1dcd3b6965fdee7a19ed6e44ec3/package.json#L116-L117

Also eagerly waiting for a fix. Thx!

@Bat-m
Copy link

Bat-m commented Jan 24, 2022

also facing the same problem with
"tailwindcss": "npm:@tailwindcss/postcss7-compat@^2.2.17",
used in ionic 5

ruyadorno added a commit to ruyadorno/cli that referenced this issue Feb 3, 2022
Fixes `npm outdated` to properly parse and display info on aliased
packages.

Fixes: npm#2800
ruyadorno added a commit to ruyadorno/cli that referenced this issue Feb 3, 2022
Fixes `npm outdated` to properly parse and display info on aliased
packages.

Fixes: npm#2800
@athrunsun
Copy link

@ruyadorno Does this issue also address #2884 and #4197 so that npm install is able to resolve aliases? Or it just fixes npm outdated specifically?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug thing that needs fixing Priority 2 secondary priority issue Release 7.x work is associated with a specific npm 7 release
Projects
None yet
Development

Successfully merging a pull request may close this issue.