docusaurus: Error when using symlinked docs folder: Module parse failed: Assigning to rvalue
🐛 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
> firkin-www@0.0.0 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
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 1
- Comments: 36 (4 by maintainers)
I have the same problem and
symlinks: falsesolve it, add this todocusaurus.config.jsand you are ready to go on symlinked folders, alsoHMRworks ok 👌:@kewp we don’t read any webpack.config.js file.
The doc to create a local plugin is very simple: https://v2.docusaurus.io/docs/using-plugins#creating-plugins https://v2.docusaurus.io/docs/lifecycle-apis#configurewebpackconfig-isserver-utils
I think something like that:
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
I see it the same way, users should be able to use symlinked docs folder.
I’m going to use it this way, I hope that this was only one problem which I come across. I’m going to use it this way because I want to have documentation to be a part of the main project and create a new repository for the docusaurus.
So I will have two repos, main project eg.
xyzand second repoxyz-github.iowhich will generate documentation with docusaurus and deploy togithub.io.xyz-github.iowill have symlinkeddocsfolder toxyz/docsfolder.Nice thank you 🙏 For me it makes sense.
Yes! @CyborgMaster this is what fixed it for me.
For me, my user folder
c:\users\karlis actually a symlink toc:\users\karlp. If I try runnpm run startfrom the symlink folder it fails but it works from the actually one!I assume what you’re thinking is correct - that webpack doesn’t understand symbolic links. Somehow some of the files are not being found.
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 urlmapping. 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.Unfortunately, I have to revert the change I made (https://github.com/facebook/docusaurus/pull/5164).
There is a bug in Webpack 5 caching and using
resolve.symlinks: falselead 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 = falsein your site for symlinks reasons, and have some monorepo UI lib symlinked, I recommend to rundocusaurus clearto be free of nasty side-effects.Also, I’m not sure using
symlinks: falseis a good solution, and webpack contributors do not seem to agree it’s a good idea to usefalseeither.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:Please let me know if this workaround works for your site.
We’ll only try to apply
symlinks: falseagain if some come up with a case where it does not work and we can’t find any other solution (repros / linked repos appreciated)That’s very much like my use case as well, just to say.
FYI I coudn’t find any reason to use
symlink: true. The code introducing this is very old and does not explain this setting (https://github.com/facebook/docusaurus/commit/2ab412e563e4aa7ac87d05edaa05ebbfb4c7d8d1)Going to revert to false in https://github.com/facebook/docusaurus/pull/5126
Using a symlinked folder as source docs seems to work fine (in dev/watchmode + prod)
Using symlinks inside the regular docs folder does not really work, and probably require more work so that features such as auto-generated sidebars etc work as intended.
Do you all have the same use-case to create a single symlink for the root docs folder?
Set
resolve.symlinks: falseis works. But when I modify the docs, the local site does not auto refresh and display the new modified content.In the latest version of watchpack (v2.x), it added a
followSymlinksoption to solve this problem, but this requires us to upgrade webpack to the latest v5.x version.Another issue with this symlinks error: https://github.com/facebook/docusaurus/issues/3579
Maybe we should consider switching symlinks to false by default. Not sure about the impact of this, so we’d rather be prepared to revert if users report bugs after release
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.