Permission denied, open '/app/package-lock.json'

this is my docker file i have error

FROM node:22.15.0-alpine3.21

RUN addgroup app && adduser -S -G app app
USER app

WORKDIR /app

COPY  package*.json .
RUN npm install 

COPY . .

EXPOSE 5173  

CMD [ "npm" , "run" , "dev" ]

[5/6] RUN npm install:
62.61 npm error code EACCES
62.61 npm error syscall open
62.62 npm error path /app/package-lock.json
62.62 npm error errno -13
62.62 npm error Error: EACCES: permission denied, open ‘/app/package-lock.json’
62.62 npm error at async open (node:internal/fs/promises:633:25)
62.62 npm error at async writeFile (node:internal/fs/promises:1207:14)
62.62 npm error at async Promise.all (index 0)
62.62 npm error at async [saveIdealTree] (/usr/local/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/reify.js:1526:7)
62.62 npm error at async Arborist.reify (/usr/local/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/reify.js:148:5)
62.62 npm error at async Install.exec (/usr/local/lib/node_modules/npm/lib/commands/install.js:150:5)
62.62 npm error at async Npm.exec (/usr/local/lib/node_modules/npm/lib/npm.js:207:9)
62.62 npm error at async module.exports (/usr/local/lib/node_modules/npm/lib/cli/entry.js:74:5) {
62.62 npm error errno: -13,
62.62 npm error code: ‘EACCES’,
62.62 npm error syscall: ‘open’,
62.62 npm error path: ‘/app/package-lock.json’
62.62 npm error }
62.62 npm error
62.62 npm error The operation was rejected by your operating system.
62.62 npm error It is likely you do not have the permissions to access this file as the current user
62.62 npm error
62.62 npm error If you believe this might be a permissions issue, please double-check the
62.62 npm error permissions of the file and its containing directories, or try running
62.62 npm error the command again as root/Administrator.
62.63 npm notice
62.63 npm notice New major version of npm available! 10.9.2 → 11.3.0
62.63 npm notice Changelog: Release v11.3.0 · npm/cli · GitHub
62.63 npm notice To update run: npm install -g [email protected]
62.63 npm notice
62.63 npm error A complete log of this run can be found in: /home/app/.npm/_logs/2025-05-11T19_29_36_093Z-debug-0.log


Dockerfile:9

ERROR: failed to solve: process “/bin/sh -c npm install” did not complete successfully: exit code: 243

please could you help me to solve this isseu

It looks like you need to check your package.json file, knowing your file structure might help. Maybe a bad pathway. Also are you installing this locally? I’ve had to configure node version manager on servers for example.

I wanna say it’s trying to look inside your app file instead of the parent folder.

Hello.
It becomes a quite long time the last time I used docker.
But you can run your container (not sure if it is mandatory).
and then connect to its shell with docker exec command.

So type something such as
docker exec -it container_id_or_name sh

Then you’ll do such commands

cd /
ls -l
cd /app
ls -l

ls -l should display the user and group of your files along with permissions represented as number or letters such as 0644 or rw-r--r-- .
Check if it is set properly.

Cheers.