vuejs / vitepress

Vite & Vue powered static site generator.
https://vitepress.dev
MIT License
11.48k stars 1.86k forks source link

Issues with peer dependencies #472

Open lampewebdev opened 2 years ago

lampewebdev commented 2 years ago

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

Kiyozz commented 2 years ago

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.

lampewebdev commented 2 years ago

@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
Kiyozz commented 2 years ago

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

lampewebdev commented 2 years ago

@Kiyozz nope just a project

brc-dd commented 2 years ago

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
kiaking commented 1 year ago

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 🤔

lampewebdev commented 1 year ago

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"
            ]
        }
    }
kiaking commented 1 year ago

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.

Zelig880 commented 1 year ago

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!

He110te4m commented 1 year ago

@kiaking

try to use this:

// package.json
{
  "peerDependenciesMeta": {
    "@type/react": {
      "optional": true
    }
  },
}
brc-dd commented 1 year ago

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

kasvith commented 1 year ago

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

benmccann commented 1 year ago

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

chenweigh commented 1 year ago

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 commented 1 year ago

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

pnpm add @algolia/client-search fixed.

brc-dd commented 9 months ago

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