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

Failed to install npm package on Docusaurus 2.0.0-beta.3 #61

Open
HazyFish opened this issue Jul 10, 2021 · 3 comments
Open

Failed to install npm package on Docusaurus 2.0.0-beta.3 #61

HazyFish opened this issue Jul 10, 2021 · 3 comments

Comments

@HazyFish
Copy link

Get the following error when running command npm i docusaurus-lunr-search --save

npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! Found: react@17.0.2
npm ERR! node_modules/react
npm ERR!   react@"^17.0.1" from the root project
npm ERR!   peer react@"^16.8.4 || ^17.0.0" from @docusaurus/core@2.0.0-beta.3
npm ERR!   node_modules/@docusaurus/core
npm ERR!     @docusaurus/core@"2.0.0-beta.3" from the root project
npm ERR!     peer @docusaurus/core@"^2.0.0-alpha.60 || ^2.0.0" from docusaurus-lunr-search@2.1.14
npm ERR!     node_modules/docusaurus-lunr-search
npm ERR!       docusaurus-lunr-search@"2.1.14" from the root project
npm ERR!   1 more (react-dom)
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer react@"^16.8.4" from docusaurus-lunr-search@2.1.14
npm ERR! node_modules/docusaurus-lunr-search
npm ERR!   docusaurus-lunr-search@"2.1.14" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.

Here is my package.json:

{
  "name": "developer-docs",
  "version": "0.0.0",
  "private": true,
  "scripts": {
    "docusaurus": "docusaurus",
    "start": "docusaurus start",
    "build": "docusaurus build",
    "swizzle": "docusaurus swizzle",
    "deploy": "docusaurus deploy",
    "clear": "docusaurus clear",
    "serve": "docusaurus serve",
    "write-translations": "docusaurus write-translations",
    "write-heading-ids": "docusaurus write-heading-ids"
  },
  "dependencies": {
    "@docusaurus/core": "2.0.0-beta.3",
    "@docusaurus/preset-classic": "2.0.0-beta.3",
    "@mdx-js/react": "^1.6.21",
    "@svgr/webpack": "^5.5.0",
    "clsx": "^1.1.1",
    "file-loader": "^6.2.0",
    "prism-react-renderer": "^1.2.1",
    "react": "^17.0.1",
    "react-dom": "^17.0.1",
    "url-loader": "^4.1.1"
  },
  "browserslist": {
    "production": [
      ">0.5%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  },
  "devDependencies": {
    "@docusaurus/module-type-aliases": "^2.0.0-beta.3",
    "@tsconfig/docusaurus": "^1.0.2",
    "@types/react": "^17.0.14",
    "@types/react-helmet": "^6.1.2",
    "@types/react-router-dom": "^5.1.8",
    "typescript": "^4.3.5"
  }
}
@danielvlla
Copy link

danielvlla commented Jul 29, 2021

Mine is working with the following package.json configuration. I'm on the latest beta version (2.0.0-beta.4)

{
  "name": "dev-docs",
  "version": "0.0.0",
  "private": true,
  "scripts": {
    "docusaurus": "docusaurus",
    "start": "docusaurus start",
    "build": "docusaurus build",
    "swizzle": "docusaurus swizzle",
    "deploy": "docusaurus deploy",
    "clear": "docusaurus clear",
    "serve": "docusaurus serve",
    "write-translations": "docusaurus write-translations",
    "write-heading-ids": "docusaurus write-heading-ids"
  },
  "dependencies": {
    "@docusaurus/core": "2.0.0-beta.4",
    "@docusaurus/preset-classic": "2.0.0-beta.4",
    "@mdx-js/react": "^1.6.21",
    "@svgr/webpack": "^5.5.0",
    "clsx": "^1.1.1",
    "docusaurus-lunr-search": "^2.1.14",
    "file-loader": "^6.2.0",
    "react": "^17.0.1",
    "react-dom": "^17.0.1",
    "url-loader": "^4.1.1"
  },
  "browserslist": {
    "production": [
      ">0.5%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  }
}

@beolson
Copy link

beolson commented Aug 30, 2021

@HazyFish - You are probably using NPM 7. NPM 7 has a little bit different behavior when it comes to child peer dependencies - NPM 6 would warn you if you did not have a matching version of a peer dependency installed. NPM 7 will try and install peer dependencies.

The easiest fix is to force NPM to act like NPM 6.

You can do that by adding a single line to your .npmrc file -

legacy-peer-deps=true

@HazyFish
Copy link
Author

@HazyFish - You are probably using NPM 7. NPM 7 has a little bit different behavior when it comes to child peer dependencies - NPM 6 would warn you if you did not have a matching version of a peer dependency installed. NPM 7 will try and install peer dependencies.

The easiest fix is to force NPM to act like NPM 6.

You can do that by adding a single line to your .npmrc file -

legacy-peer-deps=true

Thanks for the workaround! I think I can keep this issue open to track the dependency update progress.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants