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

Breaks when yarn building with latest docusaurus? #150

Closed
JaimeObregon opened this issue Jan 8, 2022 · 6 comments
Closed

Breaks when yarn building with latest docusaurus? #150

JaimeObregon opened this issue Jan 8, 2022 · 6 comments
Labels
bug Something isn't working

Comments

@JaimeObregon
Copy link

yarn build fails with this error:

Error: Cannot find module '@docusaurus/plugin-content-docs/lib/sidebars/generator'
Require stack:
- /Users/jaime/Code/c20/node_modules/docusaurus-plugin-openapi/lib/sidebars/index.js
- /Users/jaime/Code/c20/node_modules/docusaurus-plugin-openapi/lib/index.js
- ...

The relevant part of my packages.json:

"dependencies": {
    "@docusaurus/core": "^2.0.0-beta.14",
    "@docusaurus/preset-classic": "^2.0.0-beta.14",
    "@docusaurus/types": "^2.0.0-beta.14",
    "docusaurus-preset-openapi": "^0.4.2",
    // ...

So I head to my node_modules/@docusaurus/plugin-content-docs/package.json and I see:

{
  "name": "@docusaurus/plugin-content-docs",
  "version": "2.0.0-beta.fc64c12e4",

It seems yarn is resolving plugin-content-docs to 2.0.0-beta.fc64c12e4, with which docusaurus-openapi breaks.

I have retried yarn install after removing yarn.lock and flushing node_modules, to no avail.

@JaimeObregon JaimeObregon changed the title Breaks when yarn installing with latest docusaurus? Breaks when yarn building with latest docusaurus? Jan 8, 2022
@bourdakos1
Copy link
Member

Hi @JaimeObregon, I'm having trouble reproduce this issue. Do you mind sharing your yarn.lock and which version of yarn you are using?

Thanks :)

@JaimeObregon
Copy link
Author

JaimeObregon commented Jan 8, 2022

Sure, @bourdakos1. This is what I am doing:

  1. mkdir test && cd test && yarn --version:
1.22.15
  1. yarn set version berry to upgrade to latest yarn. After that, yarn --version again:
3.1.1
  1. Then set my package.json to:
{
  "name": "test",
  "private": true,
  "scripts": {
    "build": "docusaurus build",
    "clear": "docusaurus clear",
    "deploy": "docusaurus deploy",
    "docusaurus": "docusaurus",
    "serve": "docusaurus serve",
    "start": "docusaurus start --port 4000",
    "swizzle": "docusaurus swizzle",
    "write-heading-ids": "docusaurus write-heading-ids",
    "write-translations": "docusaurus write-translations"
  },
  "dependencies": {
    "@docusaurus/core": "^2.0.0-beta.14",
    "@docusaurus/preset-classic": "^2.0.0-beta.14",
    "@docusaurus/types": "^2.0.0-beta.14",
    "@mdx-js/react": "^1.6.21",
    "clsx": "^1.1.1",
    "docusaurus-preset-openapi": "^0.4.2",
    "prism-react-renderer": "^1.2.1",
    "react": "^17.0.1",
    "react-dom": "^17.0.1"
  },
  "packageManager": "yarn@3.1.1"
}
  1. After a yarn install, the yarn.lock file looks like this.

  2. Finally I run yarn build, which now fails with this stack trace:

    [ERROR] Unable to build website for locale en.
    [ERROR] Error: Qualified path resolution failed - none of those files can be found on the disk.
    
    Source path: /[REDACTED]/.yarn/__virtual__/@docusaurus-plugin-content-docs-virtual-efba689395/0/cache/@docusaurus-plugin-content-docs-npm-2.0.0-beta.fc64c12e4-9ffbefee2f-4cd5143dd7.zip/node_modules/@docusaurus/plugin-content-docs/lib/sidebars/generator
    Not found: /[REDACTED]/.yarn/__virtual__/@docusaurus-plugin-content-docs-virtual-efba689395/0/cache/@docusaurus-plugin-content-docs-npm-2.0.0-beta.fc64c12e4-9ffbefee2f-4cd5143dd7.zip/node_modules/@docusaurus/plugin-content-docs/lib/sidebars/generator
    Not found: /[REDACTED]/.yarn/__virtual__/@docusaurus-plugin-content-docs-virtual-efba689395/0/cache/@docusaurus-plugin-content-docs-npm-2.0.0-beta.fc64c12e4-9ffbefee2f-4cd5143dd7.zip/node_modules/@docusaurus/plugin-content-docs/lib/sidebars/generator.js
    Not found: /[REDACTED]/.yarn/__virtual__/@docusaurus-plugin-content-docs-virtual-efba689395/0/cache/@docusaurus-plugin-content-docs-npm-2.0.0-beta.fc64c12e4-9ffbefee2f-4cd5143dd7.zip/node_modules/@docusaurus/plugin-content-docs/lib/sidebars/generator.json
    Not found: /[REDACTED]/.yarn/__virtual__/@docusaurus-plugin-content-docs-virtual-efba689395/0/cache/@docusaurus-plugin-content-docs-npm-2.0.0-beta.fc64c12e4-9ffbefee2f-4cd5143dd7.zip/node_modules/@docusaurus/plugin-content-docs/lib/sidebars/generator.node
    
    Require stack:
    - /[REDACTED]/.yarn/__virtual__/docusaurus-plugin-openapi-virtual-63bfb31cf9/0/cache/docusaurus-plugin-openapi-npm-0.4.2-dc322e5509-d02c867c76.zip/node_modules/docusaurus-plugin-openapi/lib/sidebars/index.js
    - /[REDACTED]/.yarn/__virtual__/docusaurus-plugin-openapi-virtual-63bfb31cf9/0/cache/docusaurus-plugin-openapi-npm-0.4.2-dc322e5509-d02c867c76.zip/node_modules/docusaurus-plugin-openapi/lib/index.js
    - /[REDACTED]/.yarn/__virtual__/@docusaurus-core-virtual-d5eb8500a7/0/cache/@docusaurus-core-npm-2.0.0-beta.14-91f0a41f4d-6a5a89ecbb.zip/node_modules/@docusaurus/core/lib/server/plugins/init.js
    - /[REDACTED]/.yarn/__virtual__/@docusaurus-core-virtual-d5eb8500a7/0/cache/@docusaurus-core-npm-2.0.0-beta.14-91f0a41f4d-6a5a89ecbb.zip/node_modules/@docusaurus/core/lib/server/plugins/index.js
    - /[REDACTED]/.yarn/__virtual__/@docusaurus-core-virtual-d5eb8500a7/0/cache/@docusaurus-core-npm-2.0.0-beta.14-91f0a41f4d-6a5a89ecbb.zip/node_modules/@docusaurus/core/lib/server/index.js
    - /[REDACTED]/.yarn/__virtual__/@docusaurus-core-virtual-d5eb8500a7/0/cache/@docusaurus-core-npm-2.0.0-beta.14-91f0a41f4d-6a5a89ecbb.zip/node_modules/@docusaurus/core/lib/commands/build.js
    - /[REDACTED]/.yarn/__virtual__/@docusaurus-core-virtual-d5eb8500a7/0/cache/@docusaurus-core-npm-2.0.0-beta.14-91f0a41f4d-6a5a89ecbb.zip/node_modules/@docusaurus/core/lib/index.js
    - /[REDACTED]/.yarn/__virtual__/@docusaurus-core-virtual-d5eb8500a7/0/cache/@docusaurus-core-npm-2.0.0-beta.14-91f0a41f4d-6a5a89ecbb.zip/node_modules/@docusaurus/core/bin/docusaurus.js
        at Function.external_module_.Module._resolveFilename (/[REDACTED]/.pnp.cjs:27986:55)
        at Function.external_module_.Module._load (/[REDACTED]/.pnp.cjs:27785:48)
        at Module.require (node:internal/modules/cjs/loader:999:19)
        at require (node:internal/modules/cjs/helpers:102:18)
        at Object.<anonymous> (/[REDACTED]/.yarn/__virtual__/docusaurus-plugin-openapi-virtual-63bfb31cf9/0/cache/docusaurus-plugin-openapi-npm-0.4.2-dc322e5509-d02c867c76.zip/node_modules/docusaurus-plugin-openapi/lib/sidebars/index.js:14:21)
        at Module._compile (node:internal/modules/cjs/loader:1097:14)
        at Object.Module._extensions..js (node:internal/modules/cjs/loader:1149:10)
        at Module.load (node:internal/modules/cjs/loader:975:32)
        at Function.external_module_.Module._load (/[REDACTED]/.pnp.cjs:27835:14)
        at Module.require (node:internal/modules/cjs/loader:999:19)
        at require (node:internal/modules/cjs/helpers:102:18)
        at Object.<anonymous> (/[REDACTED]/.yarn/__virtual__/docusaurus-plugin-openapi-virtual-63bfb31cf9/0/cache/docusaurus-plugin-openapi-npm-0.4.2-dc322e5509-d02c867c76.zip/node_modules/docusaurus-plugin-openapi/lib/index.js:18:20)
        at Module._compile (node:internal/modules/cjs/loader:1097:14)
        at Object.Module._extensions..js (node:internal/modules/cjs/loader:1149:10)
        at Module.load (node:internal/modules/cjs/loader:975:32)
        at Function.external_module_.Module._load (/[REDACTED]/.pnp.cjs:27835:14)
    

@bourdakos1
Copy link
Member

Thanks, reproduced!

@bourdakos1 bourdakos1 added the bug Something isn't working label Jan 8, 2022
@bourdakos1
Copy link
Member

@JaimeObregon For some packages, it looks like yarn 3 is resolving ^2.0.0-beta.14 as 2.0.0-beta.fc64c12e4, which is an old deprecated version?

docusaurus-preset-openapi imports Docusaurus packages as ^2.0.0-beta.14, so you won't be able to fix the issue by simply pinning the versions in your package json.

However, as a temporary workaround you can use resolutions to force everything to the proper version:

"resolutions": {
  "@docusaurus/core": "2.0.0-beta.14",
  "@docusaurus/preset-classic": "2.0.0-beta.14",
  "@docusaurus/mdx-loader": "2.0.0-beta.14",
  "@docusaurus/plugin-content-docs": "2.0.0-beta.14",
  "@docusaurus/types": "2.0.0-beta.14",
  "@docusaurus/utils-validation": "2.0.0-beta.14",
  "@docusaurus/utils": "2.0.0-beta.14"
}

I'm not sure if this is a Yarn issue or a Docusaurus issue, but I recommend opening an issue with Docusaurus and link back to this issue.

@JaimeObregon
Copy link
Author

Thank you, @bourdakos1!

@JaimeObregon
Copy link
Author

Seems to be caused by a weird issue with package version sorting plus canary version names messing with SemVer. Closing this, as it's being addressed in facebook/docusaurus#6157. Thank you, @bourdakos1!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants