Gitlab ci why it remove node_modules while fetching changes and how we can skip removing

I have gitlab ci job for nodejs application I am using docker container to run node -version 8. Also, I am mounting gitlab build directory to docker. When I do npm install inside docker node_modules get root privilege. As build directory is mounted new “node_modules” get visible in build directory. Problem comes when gitlab-runner tries to fetch new changes and while fetching it remove node_modules but it gives permission denied and job stop. I tried using cache and artifact to skip node_module but no luck. I also tried changing permission of node_modules in gitlab-ci.yml after and before script.

error

Using Shell executor… Running on servername… 00:00 Fetching changes… 00:00 warning: failed to remove app/node_modules/accepts/LICENSE: Permission denied warning: failed to remove app/node_modules/accepts/HISTORY.md: Permission denied warning: failed to remove app/node_modules/accepts/README.md: Permission denied warning: failed to remove app/node_modules/accepts/index.js: Permission denied warning: failed to remove app/node_modules/accepts/package.json: Permission denied warning: failed to remove app/node_modules/lodash/_baseUnary.js: Permission denied warning: failed to remove app/node_modules/lodash/_baseGetTag.js: Permission denied warning: failed to remove app/node_modules/lodash/_baseRange.js: Permission denied warning: failed to remove app/node_modules/lodash/_baseIteratee.js: Permission denied warning: failed to remove app/node_modules/lodash/_baseReduce.js: Permission denied warning: failed to remove app/node_modules/lodash/_baseConformsTo.js: Permission denied

1 Like

Hey, did you manage to solve it?