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

ERR_PNPM_INVALID_OVERRIDE_SELECTOR  Cannot parse the "//" selector in the override on windows #4130

Open
dennislan opened this issue Dec 15, 2021 · 13 comments

Comments

@dennislan
Copy link

pnpm version: 6.24.0

Code to reproduce the issue:

windows command line execute the pnpm install

Expected behavior:

install packages

Actual behavior:

show error `ERR_PNPM_INVALID_OVERRIDE_SELECTOR  Cannot parse the "//" selector in the override'

Additional information:

  • node -v prints: 14.18.1
  • Windows, macOS, or Linux?: Windows
@dennislan
Copy link
Author

back to version 6.23.6, everything is fine.

@TemaSM
Copy link

TemaSM commented Dec 15, 2021

Confirming - Linux, Windows

Node: node:lts-alpine (v16.13.1, Alpine 3.14.3)
npm: 8.1.2
pnpm: 6.24.0

Error:

ERR_PNPM_INVALID_OVERRIDE_SELECTOR  Cannot parse the "react-dev-utils/chalk/ansi-styles" selector in the overrides

Stacktrace (found at local Windows machine while debugging):

pnpm: Cannot parse the "react-dev-utils/chalk/ansi-styles" selector in the overrides
    at parsePkgSelector (C:\\Users\\Tema\\AppData\\Roaming\\npm\\node_modules\\pnpm\\dist\\pnpm.cjs:115500:15)
    at C:\\Users\\Tema\\AppData\\Roaming\\npm\\node_modules\\pnpm\\dist\\pnpm.cjs:115492:22
    at Array.map (<anonymous>)
    at parseOverrides (C:\\Users\\Tema\\AppData\\Roaming\\npm\\node_modules\\pnpm\\dist\\pnpm.cjs:115478:40)
    at default_1 (C:\\Users\\Tema\\AppData\\Roaming\\npm\\node_modules\\pnpm\\dist\\pnpm.cjs:115524:152)
    at createReadPackageHook (C:\\Users\\Tema\\AppData\\Roaming\\npm\\node_modules\\pnpm\\dist\\pnpm.cjs:116526:58)
    at mutateModules (C:\\Users\\Tema\\AppData\\Roaming\\npm\\node_modules\\pnpm\\dist\\pnpm.cjs:116251:32)
    at async install (C:\\Users\\Tema\\AppData\\Roaming\\npm\\node_modules\\pnpm\\dist\\pnpm.cjs:116227:24)
    at async handler (C:\\Users\\Tema\\AppData\\Roaming\\npm\\node_modules\\pnpm\\dist\\pnpm.cjs:118521:31)
    at async C:\\Users\\Tema\\AppData\\Roaming\\npm\\node_modules\\pnpm\\dist\\pnpm.cjs:183629:21

Probably introduced by: #4075 or #4085

@zkochan
Copy link
Member

zkochan commented Dec 15, 2021

@TemaSM but this was never supported: react-dev-utils/chalk/ansi-styles. I guess it was just skipped in the previous versions.

You can specify only a direct parent package of a dependency and you should use a > as separator. So this will work: chalk>ansi-styles

@zkochan
Copy link
Member

zkochan commented Dec 15, 2021

@dennislan what would the "//" selector mean in the overrides? pnpm did not support such syntax. In the past it was just ignored.

Here are some examples of override keys: https://pnpm.io/package_json#pnpmoverrides

{
  "pnpm": {
    "overrides": {
      "foo": "^1.0.0",
      "quux": "npm:@myorg/quux@^1.0.0",
      "bar@^2.1.0": "3.0.0",
      "qar@1>zoo": "2"
    }
  }
}

@TemaSM
Copy link

TemaSM commented Dec 15, 2021

@zkochan my project's package.json doesn't contain any overrides. Btw, downgrading to pnpm 6.23.6 solves the problem.
UPD: found inside package.json:

  "resolutions": {
    "react-dev-utils/chalk/ansi-styles": "https://github.com/codercodingthecode/ansi-styles"
  },

@zkochan
Copy link
Member

zkochan commented Dec 15, 2021

Is this a package.json of a dependency?

@TemaSM
Copy link

TemaSM commented Dec 15, 2021

Nope, my project's package.json

@zkochan
Copy link
Member

zkochan commented Dec 15, 2021

ok, pnpm reads this field as well. It reads either pnpm.overrides or resolutions. So if you change the selector in resolutions, it should work

@TemaSM
Copy link

TemaSM commented Dec 15, 2021

Thanks, removed this obsolete for my project resolutions object (override) from package.json, and everything worked nice.
But strange, that pnpm<=6.23.6 probably ignores resolutions or handles it format differently. Because it's some sort of breaking change maybe

@vasuneet
Copy link

vasuneet commented May 8, 2023

I am having similar issue with "minimist ": "1.2.6" having in resolutions field.
Node version - 16.15.1
pnpm version - 7.18.1

Error message
ERR_PNPM_INVALID_OVERRIDE_SELECTOR  Cannot parse the "minimist " selector in the overrides

@Lan-megumi
Copy link

I have the same issue, but it look like is overrides error:

 ERR_PNPM_INVALID_OVERRIDE_SELECTOR  Cannot parse the "sass-loader/webpack" selector in the overrides

This is my package.json

"resolutions": {
    "sass-loader/webpack": "^5.0.0",
}

This is my Environment configuration

pnpm: 7.26.3
node: 16.19.0
system: win10

@AucaCoyan
Copy link

This issue is still relevant, I have this other error

 ERR_PNPM_INVALID_OVERRIDES_SELECTOR  Cannot parse the "sqlite3/node-gyp" selector in pnpm.overrides


in the overseer project.

My setup:

pnpm: 8.4.0
node: 9.8.1
system: win10

@svallory
Copy link

The issue in all examples is the wrong syntax, but it should be possible to support both yarn and pnpm by setting different values to resolutions and pnpm.overrides and currently it doesn't work.

This still returns an error in pnpm 8.12.1

"resolutions": {
    "react-dates/lodash": "^4.17.21"
  },
  "pnpm": {
    "overrides": {
      "react-dates>lodash": "^4.17.21"
    }
  },

The problem is that according to the docs

resolutions and pnpm.overrides get merged before package resolution (with pnpm.overrides taking precedence)

which makes no sense to me and doesn't work unless npm can detect that react-dates>lodash should override react-dates/lodash. But that would mean parsing and understanding the yarn format. And if pnpm understands the yarn format, then overrides becomes obsolete.

My suggestion for the core team is to disable the merging of those settings

For everyone else, there are two options:

  • Remove the parent restriction from the resolution if it is possible. It probably won't for any widespread dep (i.e. "sqlite3/node-gyp" -> "node-gyp")
  • Pick your PM and stick to it, using only it's native property and syntax

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

No branches or pull requests

7 participants