2

Please, help me handle with this error. I have tried chmod 777 on /app/node_modules but it wast a lot of time and give 777 looks wrong to me.

web-app_1     | Error: EACCES: permission denied, mkdir '/app/node_modules/.vite/deps_temp'
web-app_1     |     at Object.mkdirSync (node:fs:1386:3)
web-app_1     |     at runOptimizeDeps (file:///app/node_modules/vite/dist/node/chunks/dep-4da11a5e.js:42281:14)
web-app_1     |     at Timeout._onTimeout (file:///app/node_modules/vite/dist/node/chunks/dep-4da11a5e.js:41698:54)
web-app_1     |     at processTicksAndRejections (node:internal/process/task_queues:96:5) {
web-app_1     |   errno: -13,
web-app_1     |   syscall: 'mkdir',
web-app_1     |   code: 'EACCES',
web-app_1     |   path: '/app/node_modules/.vite/deps_temp'
web-app_1     | }

Dockerfile

ROM node:16

WORKDIR /app
COPY package.json ./
RUN mkdir -p /app/node_modules
RUN chown -R node.node /app/node_modules

# https://stackoverflow.com/questions/34498736/npm-self-signed-cert-in-chain?lq=1
RUN npm install -g npm@8.19.2
RUN npm -v
RUN npm config set strict-ssl false

RUN npm install --loglevel silly

COPY . .
USER node

CMD [ "npm", "run", "dev" ]
  • I don't understand why you have to create the `node_modules` dir, isn't `npm i` enought ? – Hollyol Oct 24 '22 at 11:58
  • `chown -R node.node /app` - node_modules might be recreated. Also put `USER` after `npm install -g`. – JeffRSon Oct 24 '22 at 12:00
  • I have a similar thing, since I packaged a node project into an operating system package and of course during runtime `vite` cannot write where it is installed. Is there a command line option or environmen variable I can use to tell `vite` to use some other directory (`/tmp/vite_temp`, e.g.)? – Golar Ramblar Jul 25 '23 at 20:54

1 Answers1

0

I have tried suggestions of change /app owner to "node" but it does't works. It only works putting "RUN chmod 777 /app/node_modules" before "CMD [ "npm", "run", "dev" ]". Thank you all.