vitepress icon indicating copy to clipboard operation
vitepress copied to clipboard

Issues with peer dependencies

Open lampewebdev opened this issue 3 years ago • 16 comments

Describe the bug

vitepress has missing peer dependencies

➜ pnpm up
Packages: +4 -4
++++----
Progress: resolved 777, reused 759, downloaded 2, added 4, done

devDependencies:
- @types/node 16.11.12
+ @types/node 16.11.13
- vitepress 0.20.6
+ vitepress 0.20.9

 WARN  Issues with peer dependencies found
.
└─┬ vitepress
  └─┬ @docsearch/js
    └─┬ @docsearch/react
      ├── ✕ missing peer @types/react@">= 16.8.0 < 18.0.0"
      ├── ✕ missing peer react@">= 16.8.0 < 18.0.0"
      ├── ✕ missing peer react-dom@">= 16.8.0 < 18.0.0"
      └─┬ @algolia/autocomplete-preset-algolia
        └── ✕ missing peer @algolia/client-search@^4.9.1
Peer dependencies that should be installed:
  @algolia/client-search@^4.9.1      react-dom@">= 16.8.0 < 18.0.0"     
  @types/react@">= 16.8.0 < 18.0.0"  react@">= 16.8.0 < 18.0.0" 

Reproduction

pnpm up or pnpm i

Expected behavior

Have no missing peer dependencies

System Info

System:
    OS: macOS 11.6.2
    CPU: (8) x64 Intel(R) Core(TM) i7-8569U CPU @ 2.80GHz
    Memory: 2.74 GB / 16.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 16.13.1 - ~/Library/pnpm/node
    Yarn: 1.22.17 - ~/Library/pnpm/yarn
    npm: 8.1.2 - ~/Library/pnpm/npm
    Watchman: 2021.12.06.00 - /usr/local/bin/watchman
  Browsers:
    Chrome: 96.0.4664.55
    Chrome Canary: 99.0.4766.0
    Firefox: 95.0
    Firefox Developer Edition: 96.0
    Firefox Nightly: 97.0a1
    Safari: 15.1
  npmPackages:
    vitepress: ^0.20.9 => 0.20.9

Additional context

No response

Validations

  • [X] Follow our Code of Conduct
  • [X] Read the docs.
  • [X] Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.

lampewebdev avatar Dec 15 '21 17:12 lampewebdev

I had this problem today, and solved it by removing all the node_modules from all sub-package and including the root node_modules.

After removing all node_modules, I just pnpm i and problem solved.

Hope it helps.

Kiyozz avatar Dec 22 '21 14:12 Kiyozz

@Kiyozz I'm still getting the error after running:

pnpm store prune
rm -rf ~/.pnpm-state ~/.pnpm-store 
pnpm prune
rm pnpm-lock.yaml
rm -rf node_modules
pnpm up

lampewebdev avatar Dec 22 '21 15:12 lampewebdev

Are you using pnpm workspace? Because the problem comes from workspace's packages node_modules

Kiyozz avatar Dec 22 '21 16:12 Kiyozz

@Kiyozz nope just a project

lampewebdev avatar Dec 23 '21 09:12 lampewebdev

Same with Yarn PnP:

➜ yarn
➤ YN0000: ┌ Resolution step
➤ YN0002: │ @docsearch/js@npm:3.0.0-alpha.42 doesn't provide @types/react (pa5c26), requested by @docsearch/react
➤ YN0002: │ @docsearch/js@npm:3.0.0-alpha.42 doesn't provide react (pcd160), requested by @docsearch/react
➤ YN0002: │ @docsearch/js@npm:3.0.0-alpha.42 doesn't provide react-dom (pa59c2), requested by @docsearch/react
➤ YN0002: │ @docsearch/react@npm:3.0.0-alpha.42 [280cb] doesn't provide @algolia/client-search (p52977), requested by @algolia/autocomplete-preset-algolia
➤ YN0000: │ Some peer dependencies are incorrectly met; run yarn explain peer-requirements <hash> for details, where <hash> is the six-letter p-prefixed code
➤ YN0000: └ Completed in 0s 219ms
➤ YN0000: ┌ Fetch step
➤ YN0000: └ Completed in 3s 291ms
➤ YN0000: ┌ Link step
➤ YN0000: │ ESM support for PnP uses the experimental loader API and is therefore experimental
➤ YN0000: └ Completed in 0s 385ms
➤ YN0000: Done with warnings in 4s 68ms

But this needs to be tracked by @algolia/docsearch instead. @docsearch/js is using @docsearch/react but with preact instead. @docsearch/react probably needs to mark @types/react, etc. as optional using peerDependenciesMeta. Currently, it is safe to ignore those warnings. They don't effect the functionality of VitePress.


On pnpm one can do this for now:

https://github.com/vuejs/vitepress/blob/45b65ce8b63bd54f345bfc3383eb2416b6769dc9/package.json#L134-L143

On yarn (berry) try this: (won't suppress the last warning)

# .yarnrc.yml
# ...

packageExtensions:
  '@docsearch/react@*':
    peerDependenciesMeta:
      '@types/react':
        optional: true
      'react':
        optional: true
      'react-dom':
        optional: true

brc-dd avatar Jan 16 '22 08:01 brc-dd

Currently VitePress package.json has:

  "pnpm": {
    "peerDependencyRules": {
      "ignoreMissing": [
        "@algolia/client-search",
        "react",
        "react-dom",
        "@types/react"
      ]
    }
  }

But it's not stopping the warning for users side. I have no idea how to stop this 🤔

kiaking avatar May 19 '22 10:05 kiaking

with pnpm 7.X in the package.json this works for me but only with pnpm.

    "pnpm": {
        "peerDependencyRules": {
            "ignoreMissing": [
                "@algolia/client-search",
                "react",
                "react-dom",
                "@types/react"
            ]
        }
    }

lampewebdev avatar May 19 '22 11:05 lampewebdev

Yes, but the developer who uses VitePress has to define that, and it's not that ideal 😓

It would be awesome if somehow we could configure VitePress's package.json or something and dodge the issue.

kiaking avatar May 19 '22 13:05 kiaking

Hi guys, I really think we should add a small note on the "Getting Started" section of the documentation about this because this is probably stopping a lot of people from getting started with Vitepress!

Zelig880 avatar Jun 26 '22 19:06 Zelig880

@kiaking

try to use this:

// package.json
{
  "peerDependenciesMeta": {
    "@type/react": {
      "optional": true
    }
  },
}

He110te4m avatar Jul 05 '22 07:07 He110te4m

@He110te4m It won't work. That needs to be there in @docsearch/react's package.json.

brc-dd avatar Jul 05 '22 08:07 brc-dd

Also encountered this problem. It worked fine with NPM though. I'll switch to PNPM when this resolves

kasvith avatar Jul 09 '22 17:07 kasvith

Here's the upstream issue: https://github.com/algolia/docsearch/issues/1272

benmccann avatar Aug 09 '22 16:08 benmccann

pnpm add vitepress

problem

 WARN  Issues with peer dependencies found
site
└─┬ vitepress 1.0.0-alpha.64
  └─┬ @docsearch/js 3.3.3
    └─┬ @docsearch/react 3.3.3
      └─┬ @algolia/autocomplete-preset-algolia 1.7.4
        └── ✕ missing peer @algolia/client-search@">= 4.9.1 < 6"
Peer dependencies that should be installed:
  @algolia/client-search@">= 4.9.1 < 6"  

Done in 4.3s

How to fix.

chenweigh avatar Mar 31 '23 07:03 chenweigh

Issue with peer dependencies of @docsearch/react algolia/docsearch#1272

pnpm add @algolia/client-search fixed.

chenweigh avatar Mar 31 '23 08:03 chenweigh

pnpm v8 has auto-install-peers=true enabled by default, so it won't give any warnings/error for new users.

brc-dd avatar Jul 27 '23 09:07 brc-dd