cannot move ‘node_modules’ to ‘_del_node_modules/node_modules’: Permission denied

I’ve noticed the following error in my node.js App Service Linux App on startup:

“mv: cannot move ‘node_modules’ to ‘_del_node_modules/node_modules’: Permission denied”

The app normally starts up fine but recently I updated a package version in package.json and the app would not start up because the new package was not getting installed.

Upon investigating I found that the the node_modules.tar.gz archive was getting updated, but not the node_modules folder that node.js actually reads from. It looks like the startup script that is supposed to unzip node_modules and copy them to the correct folder is failing with permission denied.

I’m not quite sure how to fix this. I was able to mitigate it by connecting via ssh and manually running npm install in wwwroot. This makes sure node_modules has up-to-date packages but does not seem like a viable long-term solution for process that is supposed to be automated.

I do have another Linux Web App and I connected to both via ssh, ran ls -l, and noticed that both node_modules and _del_node_modules are both supposed to be symbolic links and not directories. For some reason on my broken app they are directories.

I’m not sure how to fix this aside from maybe deleting the entire app and recreating from scratch. Any help would be appreciated.

Read more here: Source link