Why am I getting an EACCES permission denied error in my Nodejs app?

I’ve also posted on the Vitejs discussion board as I’m not sure if the source of the problem is the shopify app create node command or ViteJS, which is a dependency of the boilerplate Shopify Nodejs app.

Since yesterday I’m getting this error while running shopify app serve

node:fs:1195
┃ return handleErrorFromBinding(ctx);
┃ ^
┃
┃ Error: EACCES: permission denied, rmdir '/mnt/c/Projects/Shopify/frontend/node_modules/.vite/deps'
┃ at rmdirSync (node:fs:1195:10)
┃ at _rmdirSync (node:internal/fs/rimraf:235:5)
┃ at rimrafSync (node:internal/fs/rimraf:193:7)
┃ at rmSync (node:fs:1244:10)
┃ at removeDirSync (/mnt/c/Projects/Shopify/frontend/node_modules/vite/dist/node/chunks/dep-e1fc1d62.js:2566:9)
┃ at loadCachedDepOptimizationMetadata (/mnt/c/Projects/Shopify/frontend/node_modules/vite/dist/node/chunks/dep-e1fc1d62.js:39489:5)
┃ at createOptimizedDeps (/mnt/c/Projects/Shopify/frontend/node_modules/vite/dist/node/chunks/dep-e1fc1d62.js:59505:28)
┃ at initOptimizer (/mnt/c/Projects/Shopify/frontend/node_modules/vite/dist/node/chunks/dep-e1fc1d62.js:60072:37)
┃ at createServer (/mnt/c/Projects/Shopify/frontend/node_modules/vite/dist/node/chunks/dep-e1fc1d62.js:60096:9)
┃ at async createServer (file:///mnt/c/Projects/Shopify/frontend/server/index.js:115:12) {
┃ errno: -13,
┃ syscall: 'rmdir',
┃ code: 'EACCES',
┃ path: '/mnt/c/Projects/Shopify/frontend/node_modules/.vite/deps'
┃ }

It seems that it has something to do with write permissions to a hidden vite folder in node_modules. Before yesterday everything worked well. As far as I know I did not make any large changes, like updating npm packages or so. And it seems unlikely that I need to run the shopify app serve command using sudo.

Things that I’ve tried:

I’ve tried to create a new Shopify Nodejs boilerplate app with shopify app create node but also this app envokes the same error while serving.

I’ve also tried to rebuild packages by removing node_modules and initiated a npm install but then I get the error that there is no .git folder, so to fix this particular problem I’ve created a new boilerplate app and overwrite the existing node_modules folder by the new one. But then the original problem persists.

Anyone an idea what I’m overlooking?

I’m running
Windows 10 Pro

Windows Subsystem for Linux

Shopify v2.19.0

Vite v2.9.8

Thanks in advance!

Allan

sometimes on Linux systems a permission denied could be solved (but not an ideal workoround) via running the command with sudo.

I had a similar issue in Ubuntu 22.04 with “shopify app deploy” and “shopify app dev” and solved it by “sudo shopify app deploy”. this is quite annoying but can be a provisional workouround in order to better troubleshoot the issue. you do not have to use it always but ONLY in the occasions where the error occurs.

A side-note for non-expert linux users: use sudo only if you know what you are doing and with attention: potentially it can break your system.

Btw my specific case was with the default Remix template when building JS functions: I had to use sudo with deploy and I discovered I was forced to use sudo for dev in order to fix a “Failed to build function” app error that appeared in the app logs. It could have something to do with the fact functions are still experimental.