Skip to content

Error when using symlinked docs folder: Module parse failed: Assigning to rvalue #3272

Closed

Description

@kewp

🐛 Bug Report

Tried to run the 'classic' template following the getting started steps https://v2.docusaurus.io/docs/installation

npx @docusaurus/init@next init my-website classic

Failed when running npm run start. Lots of errors. (only showing partial log)

c:\Users\karl\firkin-www>npm run start

> [email protected] start c:\Users\karl\firkin-www
> docusaurus start

Starting the development server...

× Client
  Compiled with some errors in 3.36s

i 「wds」: Project is running at http://localhost:3000/
i 「wds」: webpack output is served from /
i 「wds」: Content not from webpack is served from c:\Users\karl\firkin-www
i 「wds」: 404s will fallback to /index.html


c:/users/karlp/firkin-www/docs/doc1.md 1:2
Module parse failed: Assigning to rvalue (1:2)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
> ---
| id: doc1
| title: Style Guide
 @ c:/users/karlp/firkin-www/.docusaurus/registry.js 1:3494-3536 1:3394-3471
 @ c:/users/karlp/firkin-www/node_modules/@docusaurus/core/lib/client/exports/ComponentCreator.js
 @ c:/users/karlp/firkin-www/.docusaurus/routes.js
 @ c:/users/karlp/firkin-www/node_modules/@docusaurus/core/lib/client/clientEntry.js
 @ multi c:/users/karlp/firkin-www/node_modules/react-dev-utils/webpackHotDevClient.js c:/users/karlp/firkin-www/node_modules/@docusaurus/core/lib/client/clientEntry.jsc:/users/karlp/firkin-www/docs/doc2.md 1:2
Module parse failed: Assigning to rvalue (1:2)

Your Environment

  • Docusaurus version used: 2.0.0-alpha.61
  • Environment name and version: node 12.8.3
  • Operating system and version: Windows 10

Activity

  1. added
    bug
    status: needs triage
    on Aug 12, 2020
  2. slorber commented on Aug 14, 2020

    @slorber
    Collaborator

    I have no idea what's going on but it works for me.

    Can someone reproduce this consistently?
    Maybe it's specific to your env (like Windows only bug? I don't have Windows).

    Can you try with yarn instead of npm? (both works for me)

    Have you modified anything at all of the generated project?

    Are you sure you are in the correct directory? I see you created my-website, yet the logs show you are in firkin-www

  3. added
    status: needs more information
    and removed
    status: needs triage
    on Aug 14, 2020
  4. kewp commented on Aug 14, 2020

    @kewp
    Author

    Hey @slorber

    I just tried this on another machine (also Windows) and it worked fine. So you may be right - it might just be my env.

    To answer your questions, though - I didn't modify anything in the generated project. And I was in the correct directory (the initial command using my-website was wrong).

  5. slorber commented on Aug 14, 2020

    @slorber
    Collaborator

    Ok great to know.

    Not sure what I can do about this issue, so I'm closing, but let's reopen it if other users are affected and we get more info.

  6. limkinZero commented on Aug 21, 2020

    @limkinZero
    Contributor

    Hi @slorber

    I`m trying to use version feature with docusaurus v2 (2.0.0-alpha.61) and get the same error:

    × Client
      Compiled with some errors in 150.24ms
    
    
    
    ./versioned_docs/version-1.1.0/doc1.md 1:2
    Module parse failed: Assigning to rvalue (1:2)
    You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
    > ---
    | id: doc1
    | title: Style Guide
     @ ./.docusaurus/registry.js 1:4301-4368 1:4145-4253
     @ ./node_modules/@docusaurus/core/lib/client/exports/ComponentCreator.js
     @ ./.docusaurus/routes.js
     @ ./node_modules/@docusaurus/core/lib/client/clientEntry.js
     @ multi ./node_modules/react-dev-utils/webpackHotDevClient.js ./node_modules/@docusaurus/core/lib/client/clientEntry.js./versioned_docs/version-1.1.0/doc2.md 1:2
    Module parse failed: Assigning to rvalue (1:2)
    You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
    > ---
    | id: doc2
    | title: Document Number 2
     @ ./.docusaurus/registry.js 1:4746-4813 1:4590-4698
     @ ./node_modules/@docusaurus/core/lib/client/exports/ComponentCreator.js
     @ ./.docusaurus/routes.js
     @ ./node_modules/@docusaurus/core/lib/client/clientEntry.js
     @ multi ./node_modules/react-dev-utils/webpackHotDevClient.js ./node_modules/@docusaurus/core/lib/client/clientEntry.js./versioned_docs/version-1.1.0/doc3.md 1:2
    Module parse failed: Assigning to rvalue (1:2)
    You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
    > ---
    | id: doc3
    | title: This is Document Number 3
     @ ./.docusaurus/registry.js 1:5373-5440 1:5218-5325
     @ ./node_modules/@docusaurus/core/lib/client/exports/ComponentCreator.js
     @ ./.docusaurus/routes.js
     @ ./node_modules/@docusaurus/core/lib/client/clientEntry.js
     @ multi ./node_modules/react-dev-utils/webpackHotDevClient.js ./node_modules/@docusaurus/core/lib/client/clientEntry.js./versioned_docs/version-1.1.0/mdx.md 1:2
    Module parse failed: Assigning to rvalue (1:2)
    You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
    > ---
    | id: mdx
    | title: Powered by MDX
     @ ./.docusaurus/registry.js 1:5809-5875 1:5657-5762
     @ ./node_modules/@docusaurus/core/lib/client/exports/ComponentCreator.js
     @ ./.docusaurus/routes.js
     @ ./node_modules/@docusaurus/core/lib/client/clientEntry.js
     @ multi ./node_modules/react-dev-utils/webpackHotDevClient.js ./node_modules/@docusaurus/core/lib/client/clientEntry.js
    
  7. deleted a comment from limkinZero on Aug 21, 2020
  8. slorber commented on Aug 21, 2020

    @slorber
    Collaborator

    Hi,

    Can you give us more infos on your env?

    Are you both on Windows?

    Wonder if you use a fs path with spaces in it or something? That can lead to issues sometimes.

  9. CyborgMaster commented on Sep 6, 2020

    @CyborgMaster

    I'm running into the same issue, when trying to use files that a symlink in from another directory. Are you aware of any issues with symlinks?

    My errors look like this

    ../idl/docs/md/all.mdx 1:2
    Module parse failed: Assigning to rvalue (1:2)
    You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
    > ---
    | id: all.proto
    | title: All
     @ ./.docusaurus/registry.js 1:4050-4105 1:3886-4014
     @ ./node_modules/@docusaurus/core/lib/client/exports/ComponentCreator.js
     @ ./.docusaurus/routes.js
     @ ./node_modules/@docusaurus/core/lib/client/clientEntry.js
     @ multi ./node_modules/react-dev-utils/webpackHotDevClient.js ./node_modules/@docusaurus/core/lib/client/clientEntry.js../idl/docs/md/bom.mdx 1:2
    Module parse failed: Assigning to rvalue (1:2)
    You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
    > ---
    | id: bom.proto
    | title: BOM
     @ ./.docusaurus/registry.js 1:4343-4398 1:4177-4307
     @ ./node_modules/@docusaurus/core/lib/client/exports/ComponentCreator.js
     @ ./.docusaurus/routes.js
     @ ./node_modules/@docusaurus/core/lib/client/clientEntry.js
     @ multi ./node_modules/react-dev-utils/webpackHotDevClient.js ./node_modules/@docusaurus/core/lib/client/clientEntry.js../idl/docs/md/bom_service.mdx 1:2
    
  10. 20 remaining items

  11. felipecrs commented on Jul 8, 2021

    @felipecrs
    Contributor

    So I will have two repos, main project eg. xyz and second repo xyz-github.io which will generate documentation with docusaurus and deploy to github.io. xyz-github.io will have symlinked docs folder to xyz/docs folder.

    That's very much like my use case as well, just to say.

  12. slorber commented on Jul 8, 2021

    @slorber
    Collaborator

    great, we'll figure out later if using symlinks inside the docs root folder is necessary.

    If you have this need please explain your usecase.

    I've added a new docs plugin instance using a root symlink so that we keep this behavior working over time. CI builds fine on linux/windows: https://deploy-preview-5126--docusaurus-2.netlify.app/docs-tests

  13. slorber commented on Jul 13, 2021

    @slorber
    Collaborator

    Unfortunately, I have to revert the change I made (#5164).

    There is a bug in Webpack 5 caching and using resolve.symlinks: false lead to deploying a Docusaurus site with stale cache entries.

    If you implement a Docusaurus plugin as part of a monorepo and change some UI code, your new deployment (dev + prod) may not see your changes. Not many sites will be affected by this in practice (theme components should be fine fine), but it's particularly painful for ourselves: Docusaurus PR Netlify deploy previews show stale UI components.

    If you decide to stick to using webpack.resolve.symlinks = false in your site for symlinks reasons, and have some monorepo UI lib symlinked, I recommend to run docusaurus clear to be free of nasty side-effects.

    Also, I'm not sure using symlinks: false is a good solution, and webpack contributors do not seem to agree it's a good idea to use false either.

    I'd like to recommend another workaround: instead of using symlinks: false, you can try to resolve the symlink to the real location, directly in your config:

        [
          '@docusaurus/plugin-content-docs',
          {
            routeBasePath: 'docs',
            sidebarPath: 'sidebars.js',
            path: fs.realpathSync('docs-symlink'),
          },
        ],

    Please let me know if this workaround works for your site.

    We'll only try to apply symlinks: false again if some come up with a case where it does not work and we can't find any other solution (repros / linked repos appreciated)

  14. changed the title [-]Couldn't start classic template: Module parse failed: Assigning to rvalue[/-] [+]Symlink + Couldn't start classic template: Module parse failed: Assigning to rvalue[/+] on Jul 21, 2021
  15. changed the title [-]Symlink + Couldn't start classic template: Module parse failed: Assigning to rvalue[/-] [+]Error when using symlinked docs folder: Module parse failed: Assigning to rvalue[/+] on Jul 21, 2021
  16. nitinkatyal1314 commented on Jul 27, 2021

    @nitinkatyal1314

    @slorber it does not seem to work, sadly.

    Can confirm on this. With { symlink: false} HMR does not work. Tried using the { followsymlinks: true} option in devServer conf, but it does not work as intended. The app recompiles on changes but the browser does not refreshes the content.

    FYI - I am not using a docusaurus plugin. Just changing webpack.dev.config.js

  17. leograba commented on Aug 9, 2021

    @leograba

    If one has a docs multi-instance and wants to share a directory with partials between two docs instances, would the symlink approach work?

  18. slorber commented on Aug 10, 2021

    @slorber
    Collaborator

    @leograba the canary now allows putting mdx docs anywhere (#5299) so you shouldn't need symlinks anymore: just import the mdx files where you want to use them.

    However keep in mind the link resolution in those partials is "simpler", it doesn't resolve relative md file paths but only regular relative/abslute links. Also there's a TOC limitation (#3915)

  19. leograba commented on Aug 10, 2021

    @leograba

    @slorber thanks! I have tested it with the canary release 0.0.0-3900 and it worked well.

    About the link resolution, I have previously noticed that that the "simpler" link resolution also affects referring to a different doc in a multi-docs setup, so I've been already using relative links. I'll keep in mind the limitations of relative links instead of relative file paths.

    About the TOC, keeping an eye on (#3915) :)

  20. slorber commented on Aug 10, 2021

    @slorber
    Collaborator

    Yes, only the docs plugin resolve relative md file paths currently and it's limited to the scope of a single instance. We need some additional infrastructure so that plugins can expose to each others a filePath => absolute url mapping. But anyway if 2 instances have different version schemes you'd rather avoid such links because it won't play well with versioning, as the versined docs would be in a totally different folders. In such case we'll probably need to support something like [SomeLink](@site/docs/myDoc.md) to make those links easier to version.

  21. slorber commented on Aug 19, 2021

    @slorber
    Collaborator

    The Webpack 5 caching bug should be resolved in webpack/webpack#14019
    Using symlinks: false should be safe again in webpack 5.51.0
    Let me know how it works for you.

  22. felipecrs commented on Apr 3, 2025

    @felipecrs
    Contributor

    @kewp we don't read any webpack.config.js file.

    The doc to create a local plugin is very simple: v2.docusaurus.io/docs/using-plugins#creating-plugins v2.docusaurus.io/docs/lifecycle-apis#configurewebpackconfig-isserver-utils

    I think something like that:

    module.exports = function(context, options) {
    return {
    name: "custom-docusaurus-plugin",
    configureWebpack(config, isServer, utils) {
    return {
    resolve: {
    symlinks: false
    }
    };
    }
    };
    };

    This doesn't work with pnpm. If I set resolve.symlinks: false, then webpack is no longer able to build the website if dependencies were installed with deno or pnpm.

    Is there any way around it?

    [
    '@docusaurus/plugin-content-docs',
    {
    routeBasePath: 'docs',
    sidebarPath: 'sidebars.js',
    path: fs.realpathSync('docs-symlink'),
    },
    ],

    This doesn't work for me because my docs path is not a symlink, but some md files inside of it are.

  23. slorber commented on Apr 4, 2025

    @slorber
    Collaborator

    This doesn't work for me because my docs path is not a symlink, but some md files inside of it are.

    As far as I know, we only support symlinking the root docs folder, not individual dirs/files inside it.

  24. felipecrs commented on Apr 4, 2025

    @felipecrs
    Contributor

    Oh. Ok. resolve.symlinks: false worked for me for years at this point, but it became an issue after deciding to switch to PNPM.

    Is this some feature you can consider supporting (i.e. should I open a separate request), or is it out of consideration?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugstatus: needs more information

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions