Docusaurus: (V2) Plugin resolution fails without require.resolve

Created on 4 Jun 2020  路  2Comments  路  Source: facebook/docusaurus

馃悰 Bug Report

When upgrading from 2.0.53 to 2.0.56 I was no longer able to run npm start as it would fail with an error that docusaurus-plugin-sass couldn't be found. I needed to modify the plugin line in docusaurus.config.js to use require.resolve instead of just the plugin name.

Have you read the Contributing Guidelines on issues?

Yes

To Reproduce

  1. Install 2.0.53
  2. Install a plugin (I used docusaurus-plugin-sass)
  3. Add plugin to docusaurus.config.js

    • plugins: ['docusaurus-plugin-sass']

  4. Run npm start
  5. Observe failure
  6. Change plugin config to: plugins: [require.resolve('docusaurus-plugin-sass')]
  7. Run npm start
  8. Observe proper behavior

Expected behavior

Docusaurs would start

Actual Behavior

卤 npm start

> [email protected] start /Users/Dianoga/projects/developer-docs
> docusaurus start

Starting the development server...
Error: Cannot find module 'docusaurus-plugin-sass'
Require stack:
- /Users/Dianoga/projects/developer-docs
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:982:15)
    at Function.resolve (internal/modules/cjs/helpers.js:83:19)
    at /Users/Dianoga/projects/developer-docs/node_modules/@docusaurus/core/lib/server/plugins/init.js:40:67
    at Array.map (<anonymous>)
    at Object.initPlugins (/Users/Dianoga/projects/developer-docs/node_modules/@docusaurus/core/lib/server/plugins/init.js:22:10)
    at Object.loadPlugins (/Users/Dianoga/projects/developer-docs/node_modules/@docusaurus/core/lib/server/plugins/index.js:47:28)
    at Object.load (/Users/Dianoga/projects/developer-docs/node_modules/@docusaurus/core/lib/server/index.js:57:62)
    at start (/Users/Dianoga/projects/developer-docs/node_modules/@docusaurus/core/lib/commands/start.js:45:34)
    at /Users/Dianoga/projects/developer-docs/node_modules/@docusaurus/core/bin/docusaurus.js:29:5
    at Command.<anonymous> (/Users/Dianoga/projects/developer-docs/node_modules/@docusaurus/core/bin/docusaurus.js:97:23)
    at Command.listener (/Users/Dianoga/projects/developer-docs/node_modules/commander/index.js:370:29)
    at Command.emit (events.js:311:20)
    at Command.parseArgs (/Users/Dianoga/projects/developer-docs/node_modules/commander/index.js:892:12)
    at Command.parse (/Users/Dianoga/projects/developer-docs/node_modules/commander/index.js:642:21)
    at Object.<anonymous> (/Users/Dianoga/projects/developer-docs/node_modules/@docusaurus/core/bin/docusaurus.js:120:5)
    at Module._compile (internal/modules/cjs/loader.js:1158:30)

Your Environment

  • Docusaurus version used: 2.0.0-alpha.56
  • Environment name and version: Node 12.16.1, NPM 6.13.4
  • Operating system and version (desktop or mobile): Mac

Reproducible Demo

I don't have one right now. Sorry!

bug

Most helpful comment

Every time I actually report a bug somewhere I find that there's something obvious that I didn't see 馃う

Thanks for pointing out the release notes 馃槃

All 2 comments

Thanks for reporting! It's both a bug and a breaking change. Read the release notes for the workaround. We'll release a fix soon such that you shouldn't need to do that.

Every time I actually report a bug somewhere I find that there's something obvious that I didn't see 馃う

Thanks for pointing out the release notes 馃槃

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ericnakagawa picture ericnakagawa  路  3Comments

itelofilho picture itelofilho  路  3Comments

omry picture omry  路  3Comments

JoelMarcey picture JoelMarcey  路  3Comments

philipmjohnson picture philipmjohnson  路  3Comments