plouc / nivo

nivo provides a rich set of dataviz components, built on top of the awesome d3 and React libraries
https://nivo.rocks
MIT License
13.19k stars 1.03k forks source link

npm ERR! code EUNSUPPORTEDPROTOCOL (v0.82.0) #2319

Closed blaxk closed 1 year ago

blaxk commented 1 year ago

I was using the v0.80.0 version without problems. But while trying to install version v0.82.0 I got an error.

npm ERR! code EUNSUPPORTEDPROTOCOL
npm ERR! Unsupported URL Type "workspace:": workspace:*

package.json

{
   ...
   "dependencies": {
      ...
      "@nivo/bar": "0.80.0",
      "@nivo/core": "0.80.0",
      "@nivo/line": "0.80.0",
      "@nivo/pie": "0.80.0",
      "next": "13.3.4",
      "react": "18.2.0",
      "react-dom": "18.2.0",
   },
   "devDependencies": {
      "eslint-config-next": "13.3.4"
   }
}
plouc commented 1 year ago

I switched to pnpm and the workspace protocol is the recommendation for monorepos, although [it should be replaced eventually according to the doc, it might be due to lerna.

That's a pretty big issue, I'll try to release a new version without this issue asap, for now please stick with your current version.

plouc commented 1 year ago

So it does update the main dependencies with proper versions:

"dependencies": {
    "@nivo/scales": "0.82.0",
    "@react-spring/web": "9.4.5 || ^9.7.2",
    "@types/d3-format": "^1.4.1",
    "@types/d3-time-format": "^2.3.1",
    "@types/prop-types": "^15.7.2",
    "d3-format": "^1.4.4",
    "d3-time-format": "^3.0.0",
    "prop-types": "^15.7.2"
},

But the peer dependencies still use the workspace protocol:

"peerDependencies": {
    "@nivo/core": "workspace:*",
    "react": ">= 16.14.0 < 19.0.0"
},

I need to see if lerna mentions anything about this.

plouc commented 1 year ago

Opened an issue on lerna.

wheresvic commented 1 year ago

I was able to get around this with the --legacy-peer-deps flag.

plouc commented 1 year ago

Thank you for sharing this @wheresvic.

ghiscoding commented 1 year ago

@plouc hello, I'm the maintainer of Lerna-Lite I prefer to write you directly here since it's probably better not to promote Lerna forks in Lerna directly, so anyway... Lerna-Lite does support bumping peer deps but under a flag (version#--allow-peer-dependencies-update) since by default peer deps should in theory never be updated unless explicitly wanting to (hence the flag). Also note that I pushed a fix in Lerna-Lite for an issue reported with workspace:^ in peer deps, I'll release a new version tonight, so it might be better to wait tomorrow if you ever want to give it a try

I also replied to your Lerna issue by mentioning why Lerna does not yet support this feature.

Just wanted to provide more info and possible alternative... cheers

Christopher-Stolfa commented 1 year ago

I managed to install this package by selecting the previous version npm i @nivo/core@^0.81.0.

plouc commented 1 year ago

@ghiscoding, thank you for reaching out, and for the reply on the lerna issue I opened! I might give it a try.

plouc commented 1 year ago

Actually, maybe for now I'll move @nivo/core to a regular dependency, the only benefit is to prevent potential duplication, but on the other hand, all other core dependencies (@nivo/tooltip, @nivo/scales, @nivo/axes...) are currently expressed as regular ones.

The current approach also comes with some limitations, it means that you need to have all versions strictly aligned, which might be an issue for users who cannot/don't want to upgrade all charts at once.

With this new approach, they could, at the expense of a bigger bundle size though.

@nivo/core is not like other peer dependencies such as React or babel, where only one version should exist, it's OK to have several versions (but will affect the resulting bundle size).

chelouche9 commented 1 year ago

Happened to me as well. We only have one component using nivo so we just downgraded the version and it works

npm i @nivo/core@0.80.0 @nivo/pie@0.80.0
mirogajdos commented 1 year ago

Same issue after bumping version from 0.81.0 to 0.82.1

$ node -v
v18.16.0
$ npm -v
9.5.1
$ npm ci --cache .npm --prefer-offline
npm ERR! code EUNSUPPORTEDPROTOCOL
npm ERR! Unsupported URL Type "workspace:": workspace:*
npm ERR! A complete log of this run can be found in:
plouc commented 1 year ago

Moved @nivo/core as a regular dependency.