linaria icon indicating copy to clipboard operation
linaria copied to clipboard

React 17 not in peerDeps (breaks npm v7)

Open ntucker opened this issue 3 years ago • 8 comments

Environment

react>=17

  • Linaria version: @linaria/[email protected]
  • Bundler (+ version): webpack 5
  • Node.js version: v14.13.1
  • OS: Ubuntu
  • npm: 7.7.5

Description

Warnings in most package installers, npm 7 will outright fail due to this problem. Cannot use with React 17.

npm ERR! Found: [email protected]
npm ERR! node_modules/react
npm ERR!   dev react@"latest" from the root project
npm ERR!   peer react@">=16" from @linaria/[email protected]
npm ERR!   node_modules/@linaria/react
npm ERR!     dev @linaria/react@"^3.0.0-beta.1" from the root project
npm ERR!   22 more (@rest-hooks/test, @rest-hooks/core, rest-hooks, ...)

ntucker avatar Mar 28 '21 19:03 ntucker

linaria specifies react >=16:

https://github.com/callstack/linaria/blob/4ee73ae362ca775999bf71c93279db5268108d13/packages/react/package.json#L51

Maybe it's coming from another dependency ?

Specific to npm, you may be able to bypass the problem with --legacy-peer-deps, which I've had to use on multiple occasions in the past year or so.

avindra avatar Mar 28 '21 20:03 avindra

This isn't blocking me from installing (I used the --legacy-peer-deps as suggested) but I'm worried about others and the friction it creates.

PS) Updated report with the output of command....I think the new npm has some weird no logic for matching

ntucker avatar Mar 28 '21 21:03 ntucker

Trying package.json entry from latest to actual version and get same thing:

npm ERR! Found: [email protected]
npm ERR! node_modules/react
npm ERR!   dev react@"^17.0.2" from the root project
npm ERR!   peer react@">=16" from @linaria/[email protected]
npm ERR!   node_modules/@linaria/react
npm ERR!     dev @linaria/react@"^3.0.0-beta.1" from the root project
npm ERR!   22 more (@rest-hooks/test, @rest-hooks/core, rest-hooks, ...)

ntucker avatar Mar 28 '21 21:03 ntucker

I believe they expect explicit versions listed with || now. "NPM modules must name specific versions of their peerDependencies"

More here: https://blog.npmjs.org/post/626173315965468672/npm-v7-series-beta-release-and-semver-major

ntucker avatar Mar 28 '21 21:03 ntucker

Hi @ntucker!

Could you please provide a repo? I've tried to reproduce the error but everything seems ok:

➜  linaria-743 cat package.json | grep "react"
    "@linaria/react": "^3.0.0-beta.1",
    "react": "latest"
➜  linaria-743 npm install

added 8 packages, and audited 9 packages in 2s

found 0 vulnerabilities

https://semver.npmjs.com says that there is no difference between >=16 and >=16 || >=17.

Anber avatar Mar 29 '21 09:03 Anber

Similar issue, I can't install when preact is present in the project npm:@preact/compat, had to use --legacy-peer-deps. Using npm v7.

npm ERR! While resolving: [email protected]
npm ERR! Found: [email protected]
npm ERR! node_modules/react
npm ERR!   react@"npm:@preact/[email protected]" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer react@">=16" from @linaria/[email protected]
npm ERR! node_modules/@linaria/react
npm ERR!   @linaria/react@"^3.0.0-beta.4" from the root project

heyitsarpit avatar May 29 '21 07:05 heyitsarpit

Hi @ntucker!

Could you please provide a repo? I've tried to reproduce the error but everything seems ok:

➜  linaria-743 cat package.json | grep "react"
    "@linaria/react": "^3.0.0-beta.1",
    "react": "latest"
➜  linaria-743 npm install

added 8 packages, and audited 9 packages in 2s

found 0 vulnerabilities

https://semver.npmjs.com says that there is no difference between >=16 and >=16 || >=17.

The key is using npm 7 - not something normally enforceable in a repo.

ntucker avatar May 29 '21 16:05 ntucker

The key is using npm 7 - not something normally enforceable in a repo.

➜  npm --version
7.7.5

¯\_(ツ)_/¯

Probably, there is another factor. That's why I asked for a repo.

Anber avatar Jun 06 '21 12:06 Anber

> npm -v
8.19.4
> npm install react@17
added 4 packages, and audited 5 packages in 858m
> npm install @linaria/react
added 80 packages, and audited 85 packages in 14s

No errors or warnings related to peerDependencies.

layershifter avatar Sep 28 '23 19:09 layershifter