ds300 / patch-package

Fix broken node modules instantly 🏃🏽‍♀️💨

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Patch Package fails on Gitlab CI (Docker)

katoha opened this issue · comments

When trying to run a patch-package during a Docker build on CI (Gitlab) it fails with the following error.

npm WARN lifecycle <packagename>~postinstall: cannot run in wd <packagename> patch-package (wd=/app)

In order to fix this you need to add a .npmrc file with the following declaration making sure to copy the file to your Dockerfile.

unsafe-perm = true

The above information should be added to the README.md file for other users

Thank you for mentioning this! Saved me a lot of headache in our build process :)

I added this to the README. Thanks so much for sharing 🙏 ❤️

a bit off topic but if you are running on docker remember also to copy your .npmrc and patches folder inside the workdir!

Another solution is to run npm in your container as a non-root user.

If you're using the official node Docker images, it ships with a non-root user called node: https://github.com/nodejs/docker-node/blob/main/docs/BestPractices.md#non-root-user