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

Error Invalid Semver Range for npm: alias protocol #151

Closed
danielpza opened this issue Jul 25, 2023 · 3 comments
Closed

Error Invalid Semver Range for npm: alias protocol #151

danielpza opened this issue Jul 25, 2023 · 3 comments

Comments

@danielpza
Copy link

Description

Syncpack is throwing an error when encountering a npm: alias protocol in the package.json definition

TypeError: Invalid SemVer Range: npm:@mui/styled-engine-sc@^5.12.0

I'm using @mui/material with styled-components, this is a valid package.json dependency entry:

		"@mui/material": "5.13.6",
		"@mui/styled-engine": "npm:@mui/styled-engine-sc@^5.12.0",
		"@mui/styled-engine-sc": "5.12.0",

See https://mui.com/material-ui/guides/styled-engine/

Suggested Solution

Syncpack should recognize the npm: alias protocol https://yarnpkg.com/features/protocols

Help Needed

@JamieMason
Copy link
Owner

JamieMason commented Jul 26, 2023

Looking at https://docs.npmjs.com/cli/v9/using-npm/package-spec, it lists a lot of variations of package specs supported by npm, which we can use as a checklist for what to support.

Importantly, it also lists https://www.npmjs.com/package/npm-package-arg which is new to me. It looks like it could be the missing piece for a lot of open issues, as it handles the awkward protocols (npm:, workspace:, link: etc) which are out of scope for https://github.com/npm/node-semver, currently used by syncpack.

EDIT: Output for the OP's example of npa('npm:@mui/styled-engine-sc@^5.12.0');

Result {
  type: 'alias',
  registry: true,
  where: undefined,
  raw: 'npm:@mui/styled-engine-sc@^5.12.0',
  name: undefined,
  escapedName: undefined,
  scope: undefined,
  rawSpec: 'npm:@mui/styled-engine-sc@^5.12.0',
  saveSpec: null,
  fetchSpec: null,
  gitRange: undefined,
  gitCommittish: undefined,
  gitSubdir: undefined,
  hosted: undefined,
  subSpec: Result {
    type: 'range',
    registry: true,
    where: undefined,
    raw: '@mui/styled-engine-sc@^5.12.0',
    name: '@mui/styled-engine-sc',
    escapedName: '@mui%2fstyled-engine-sc',
    scope: '@mui',
    rawSpec: '^5.12.0',
    saveSpec: null,
    fetchSpec: '^5.12.0',
    gitRange: undefined,
    gitCommittish: undefined,
    gitSubdir: undefined,
    hosted: undefined
  }
}

@JamieMason
Copy link
Owner

Released in 10.9.3, more work may be needed but let me know how this goes.

@JamieMason
Copy link
Owner

Update: 12.0.0-alpha.0 adds better support for non-semver version formats.

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

2 participants