facebook / docusaurus

Easy to maintain open source documentation websites.
https://docusaurus.io
MIT License
55.96k stars 8.4k forks source link

Docusaurus v2 doesn't run in WSL2 Ubuntu20.x #5188

Closed tirthaguha closed 3 years ago

tirthaguha commented 3 years ago

🐛 Doesn't run on WSL2 on Ubuntu 20.x

Prerequisites

  1. win10
  2. WSL2
  3. Ubuntu 20.x
  4. nvm
  5. Node v14.15.1
  6. npm v6.14.8

Description

(A clear and concise description of what the bug is.)

Have you read the Contributing Guidelines on issues?

Yes

Steps to reproduce

(Write your steps here:)

Unsing npm, not yarn.

  1. Create a new docusarus project (npx @docusaurus/init@latest init my-website classic)
  2. npm start (takes 10-15 mins to launch)
  3. Change in any md file in /docs
  4. the change never reflects in the browser.

Expected behavior

Should work, as it works in windows

Actual behavior

Obviously broken.

Your environment

@docusaurus/core: 2.0.0-beta.2

Rest mentioned in the prerequisites

Reproducible demo

:-(

tirthaguha commented 3 years ago

Not sure if this will help, but I've found that nodemon doesn't work on WSL2 either. However, webpack-dev-server, bundled with create-react-app boilerplates or otherwise, seems to work fine.

slorber commented 3 years ago

It's not clear what "doesn't run" mean. Is there any error message? Your description looks like it does run, but it does not update/hot-reload, which is a different problem.

Please try the same with canary https://docusaurus.io/community/canary Make sure you don't use any symlink

I don't have Windows / WSL2 so it's unlikely I'll be able to work on this myself anytime soon, help from the community wanted

tirthaguha commented 3 years ago

Not sure if this will help, but here are the logs.

$ npm start

> pages@0.0.0 start /path/path/pages
> docusaurus start

Starting the development server...
Docusaurus website is running at "http://localhost:3000/pages/".

✔ Client
  Compiled successfully in 57.72s

ℹ 「wds」: Project is running at http://localhost:3000/
ℹ 「wds」: webpack output is served from /pages/
ℹ 「wds」: Content not from webpack is served from /path/path/pages
ℹ 「wds」: 404s will fallback to /index.html

● Client █████████████████████████ done (99%) plugins
 WebpackDevMiddleware

Watchpack Error (initial scan): Error: EACCES: permission denied, lstat '/mnt/f/pagefile.sys'
slorber commented 3 years ago

For sure it helps, how can we help if we don't even know the error message?

Error: EACCES: permission denied

This might be a problem on your system (in case you abuse usage of sudo or have permissions not configured correctly). For now I'm going to close this issue. If you/someone else can reproduce it on another Windows/WSL2 computer, we'll re-open as it would be a proof it's not a problem on your specific computer.

tirthaguha commented 3 years ago

I found these threads https://github.com/h-yoshikawa44/portfolio/issues/10

I don't think this issue should be closed. Although not an issue with this repo, but it certainly is an issue with one of its dependencies. You should wait till the original issue with Watchpack is closed. https://github.com/webpack/watchpack/issues/187

slorber commented 3 years ago

Ok let's re-open then but there's probably not much I can do to solve it

pranabdas commented 3 years ago

@tirthaguha I think it is bad idea to keep project files in Windows file system (especially node_modules folder which contains tens of thousands of files) and run node in WSL2. Even if your permission error is solved, the cross system file access would be extremely slow giving bad development experience. How about you move your project directory inside WSL2 filesystem?

# copy between file systems without node_modules (later install npm packages)
rsync -r /mnt/f/my_website/ --exclude node_modules --delete ~/my_website
cd ~/my_website
npm install
# you can even open your project folder in Windows VS Code
code .

Now it should work as you would expect.

teikjun commented 3 years ago

@tirthaguha I agree with the suggestion from @pranabdas. It seems like you installed node in the linux filesystem and your Docusaurus project in the windows file system. This is not the intended usage of WSL2 and it is the likely cause of the permission issue and slow performance that you are facing.

Both your tools (e.g. node) and project files (e.g. Docusaurus) should be installed in the same filesystem (the linux filesystem in this case). Please refer to https://docs.microsoft.com/en-us/windows/wsl/setup/environment#file-storage for the best practices of using WSL2. Here's the relevant section for your current issue:

slorber commented 3 years ago

thanks

Let's close this now and hopefully the problem will be solved with the above advices