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

Vue Vite Docker WSL2. Internal server error: EACCES: permission denied, stat '/root/.node_modules/plugin-vue:export-helper' #6767

Closed
7 tasks done
sshiling opened this issue Feb 5, 2022 · 20 comments · Fixed by #7612
Labels
p3-minor-bug An edge case that only affects very specific usage (priority)

Comments

@sshiling
Copy link

sshiling commented Feb 5, 2022

Describe the bug

Error running dev server in WSL2 Docker.

docker-compose:

  frontend:
    build: .
    command: npm run dev
    volumes:
      - ./:/frontend
    ports:
      - '8080:8080'

Dockerfile:

FROM node:lts-alpine
WORKDIR /frontend
COPY package*.json ./
RUN npm install
COPY . .
CMD ["npm", "run", "dev"]

vite.config.js:

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [vue()],
  server: {
    host: true,
    port: 8080
  }
})

screenshot4

Reproduction

https://github.com/sshiling/Vite-Vue-Docker-WSL2-Bug

System Info

System:
    OS: Linux 4.19 Ubuntu 20.04 LTS (Focal Fossa)        
    CPU: (1) x64 Intel(R) Core(TM) i5-9400F CPU @ 2.90GHz
    Memory: 129.67 MB / 979.44 MB
    Container: Yes
    Shell: 5.8 - /usr/bin/zsh
  Binaries:
    Node: 16.13.2 - ~/.nvm/versions/node/v16.13.2/bin/node
    Yarn: 1.22.5 - /usr/bin/yarn
    npm: 6.14.15 - /usr/bin/npm

Used Package Manager

npm

Logs

frontend_1  |   vite v2.7.13 dev server running at:
frontend_1  |
frontend_1  |   > Local:    http://localhost:8080/
frontend_1  |   > Network:  http://172.19.0.2:8080/
frontend_1  |
frontend_1  |   ready in 259ms.
frontend_1  |
frontend_1  | 2:31:01 PM [vite] Internal server error: EACCES: permission denied, stat '/root/.node_modules/plugin-vue:export-helper'
frontend_1  |   Plugin: vite:import-analysis
frontend_1  |   File: /frontend/src/App.vue
frontend_1  |       at Object.statSync (node:fs:1536:3)
frontend_1  |       at isDirectory (/frontend/node_modules/resolve/lib/sync.js:31:23)
frontend_1  |       at loadNodeModulesSync (/frontend/node_modules/resolve/lib/sync.js:200:17)
frontend_1  |       at Function.resolveSync [as sync] (/frontend/node_modules/resolve/lib/sync.js:107:17)
frontend_1  |       at resolveFrom$3 (/frontend/node_modules/vite/dist/node/chunks/dep-f5552faa.js:3911:29)
frontend_1  |       at resolvePackageData (/frontend/node_modules/vite/dist/node/chunks/dep-f5552faa.js:30046:19)
frontend_1  |       at /frontend/node_modules/vite/dist/node/chunks/dep-f5552faa.js:30426:15
frontend_1  |       at Array.find (<anonymous>)
frontend_1  |       at tryNodeResolve (/frontend/node_modules/vite/dist/node/chunks/dep-f5552faa.js:30425:44)
frontend_1  |       at Context.resolveId (/frontend/node_modules/vite/dist/node/chunks/dep-f5552faa.js:30257:28)

Validations

@M0hammedImran
Copy link

This is happening to me as well.
But I'm on PopOs, i don't think this is something to do with WSL.

frontend  | error when starting dev server:
frontend  | Error: Build failed with 11 errors:
frontend  | node_modules/.pnpm/resolve@1.22.0/node_modules/resolve/lib/sync.js:31:22: error: [plugin: vite:dep-scan] EACCES: permission denied, stat '/root/.node_modules/@heroicons/react/outline/SearchIcon'
frontend  | node_modules/.pnpm/resolve@1.22.0/node_modules/resolve/lib/sync.js:31:22: error: [plugin: vite:dep-scan] EACCES: permission denied, stat '/root/.node_modules/@heroicons/react/outline/SearchIcon'
frontend  | node_modules/.pnpm/resolve@1.22.0/node_modules/resolve/lib/sync.js:31:22: error: [plugin: vite:dep-scan] EACCES: permission denied, stat '/root/.node_modules/@heroicons/react/outline/SearchIcon'
frontend  | node_modules/.pnpm/resolve@1.22.0/node_modules/resolve/lib/sync.js:31:22: error: [plugin: vite:dep-scan] EACCES: permission denied, stat '/root/.node_modules/dayjs/plugin/relativeTime'
frontend  | node_modules/.pnpm/resolve@1.22.0/node_modules/resolve/lib/sync.js:31:22: error: [plugin: vite:dep-scan] EACCES: permission denied, stat '/root/.node_modules/dayjs/plugin/relativeTime'
frontend  | ...
frontend  |     at failureErrorWithLog (/app/client/node_modules/.pnpm/esbuild@0.13.15/node_modules/esbuild/lib/main.js:1493:15)
frontend  |     at /app/client/node_modules/.pnpm/esbuild@0.13.15/node_modules/esbuild/lib/main.js:1151:28
frontend  |     at runOnEndCallbacks (/app/client/node_modules/.pnpm/esbuild@0.13.15/node_modules/esbuild/lib/main.js:941:63)
frontend  |     at buildResponseToResult (/app/client/node_modules/.pnpm/esbuild@0.13.15/node_modules/esbuild/lib/main.js:1149:7)
frontend  |     at /app/client/node_modules/.pnpm/esbuild@0.13.15/node_modules/esbuild/lib/main.js:1258:14
frontend  |     at /app/client/node_modules/.pnpm/esbuild@0.13.15/node_modules/esbuild/lib/main.js:629:9
frontend  |     at handleIncomingPacket (/app/client/node_modules/.pnpm/esbuild@0.13.15/node_modules/esbuild/lib/main.js:726:9)
frontend  |     at Socket.readFromStdout (/app/client/node_modules/.pnpm/esbuild@0.13.15/node_modules/esbuild/lib/main.js:596:7)
frontend  |     at Socket.emit (node:events:390:28)
frontend  |     at addChunk (node:internal/streams/readable:315:12)
frontend exited with code 1

@ghost
Copy link

ghost commented Feb 8, 2022

Getting the same error on Ubuntu 20.04 in combination with docker

@ghost
Copy link

ghost commented Feb 8, 2022

Downgrading to 2.6.14 works as a quick workaround but should not be the fix. @patak-dev do you have any solution?

@M0hammedImran
Copy link

Downgrading to 2.6.14 works as a quick workaround but should not be the fix. @patak-dev do you have any solution?

This works

@joepagan
Copy link

joepagan commented Feb 10, 2022

Getting this on node:16-alpine with 2.6.14

@joepagan
Copy link

Just tried yarn install and yarn dev and that works... maybe it's an issue upstream with npm?

@Yakoot
Copy link

Yakoot commented Feb 21, 2022

same problem, but works fine on node:16 with 2.6.14

@f-nyx
Copy link

f-nyx commented Feb 25, 2022

I still get the error with both node-16 and node-16-alpine using version 2.6.14.

I found a workaround, if you mount your source directory in /root it works. This docker-compose.yml configuration works for me:

version: '3.2'
services:
  frontend:
    image: node:16-alpine
    working_dir: /root
    volumes:
      - ./frontend:/root
    command: npx vite --host

@FedericoBiccheddu
Copy link

Just tried yarn install and yarn dev and that works... maybe it's an issue upstream with npm?

Using yarn seems resolve the problem.

For context:
Docker: node:16.14-alpine
npm: v8.3.1

@bbbboom
Copy link
Contributor

bbbboom commented Mar 1, 2022

It looks like this resolve#pull should be causing the problem.

@GonerGenesis
Copy link

GonerGenesis commented Mar 21, 2022

I still get the error with both node-16 and node-16-alpine using version 2.6.14.

I found a workaround, if you mount your source directory in /root it works. This docker-compose.yml configuration works for me:

version: '3.2'
services:
  frontend:
    image: node:16-alpine
    working_dir: /root
    volumes:
      - ./frontend:/root
    command: npx vite --host

Worked for me but 'Ugh'. I ran into it by setting up a docker dev environment for a svelte kit app with vite.ssr.noExternalize option enabled for three.js

@Randomneo
Copy link

Same here on just linux (its not WSL problem). Solved with installing 2.5 version of vite

npm install vite@2.5

why i'm doing frontend??? :(

@Ca-moes
Copy link

Ca-moes commented Mar 27, 2022

Same here on just linux (its not WSL problem). Solved with installing 2.5 version of vite

npm install vite@2.5

why i'm doing frontend??? :(

Which Node version/docker image? Also trying to get it to work and currently using node:lts-gallium

@sarkiroka
Copy link

node@16 and vite@2.6.14 combo is works. 👍

vite@2.9.1 doesn't works well in docker. It show permission denied error message in docker. 👎

@marcianos
Copy link

Node@16 & Vite until version 2.7.0-beta.7 works.

Vite 2.7.0-beta.8 does not work because it shows a permission denied error with docker.

@patak-dev patak-dev added p3-minor-bug An edge case that only affects very specific usage (priority) and removed pending triage labels Apr 4, 2022
@playmean
Copy link

playmean commented Apr 5, 2022

It's not an issue with resolve package. You are running container with different user than your mounted project's files owner.

It breaks on vite v2.7.0-beta.8 because fs.statSync() exceptions became preserved.

I don't remember where is line of code exactly, but I fixed this by running docker container with -u 1000 option (where 1000 - uid of project's files owner)

@patak-dev
Copy link
Member

@playmean do you know why @bbbboom PR fixes the issue then? I couldn't try myself, could someone else confirm that the PR is having an effect on your projects?

@playmean
Copy link

playmean commented Apr 5, 2022

@patak-dev I have checked now, yes, PR fixes the issue. But I think first of all this is a problem with containerized environment, just for notice.

@playmean
Copy link

playmean commented Apr 5, 2022

I think this PR breaks native feature of Node that described here.

image

@patak-dev
Copy link
Member

patak-dev commented Apr 5, 2022

@playmean I saw that in the linked resolve PR, and it looks extremely rare. For the record, we merged #7612 because the change in resolve is causing real issues without any real bug report to justify it.
I agree that the best would be to follow node, but I think we should do it once we get an issue with a setup that justifies this change. And adding these paths should be accompanied probably with other changes to avoid breaking other use cases, or properly document how to correct them, as the setup looks common enough.

@github-actions github-actions bot locked and limited conversation to collaborators Apr 20, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
p3-minor-bug An edge case that only affects very specific usage (priority)
Projects
None yet
Development

Successfully merging a pull request may close this issue.