gatsby: Error: EACCES: permission denied - Creating new gatsby app in WSL (Ubuntu 18.04)

Description

Hi, after installing gatsby globally in my WSL terminal i’m receiving the below error when running gatsby new blog https://github.com/gatsbyjs/gatsby-starter-hello-world

Steps to reproduce

1.Install WSL Ubuntu 18.04 2.Curl install npm 3.Install gatsby with npm install -g gatsby-cli 4.New gatsby app with gatsby new blog https://github.com/gatsbyjs/gatsby-starter-hello-world

Expected result

Create a new app without an errors

Actual result

Logs below

gareth@DESKTOP-5ANEVFU:~/blog-website/services$ gatsby new blog https://github.com/gatsbyjs/gatsby-starter-hello-world
info Creating new site from git: https://github.com/gatsbyjs/gatsby-starter-hello-world.git
Cloning into 'blog'...
remote: Enumerating objects: 16, done.
remote: Counting objects: 100% (16/16), done.
remote: Compressing objects: 100% (12/12), done.
remote: Total 16 (delta 0), reused 9 (delta 0), pack-reused 0
Unpacking objects: 100% (16/16), done.
success Created starter directory layout
info Installing packages...
✔ Which package manager would you like to use ? › npm
info Preferred package manager set to "npm"
npm ERR! code EACCES
npm ERR! syscall rename
npm ERR! path /home/gareth/blog-website/services/blog/node_modules/babel-runtime
npm ERR! dest /home/gareth/blog-website/services/blog/node_modules/.babel-runtime.DELETE
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, rename '/home/gareth/blog-website/services/blog/node_modules/babel-runtime' -> '/home/gareth/blog-website/services/blog/node_modules/.babel-runtime.DELETE'
npm ERR!  [OperationalError: EACCES: permission denied, rename '/home/gareth/blog-website/services/blog/node_modules/babel-runtime' -> '/home/gareth/blog-website/services/blog/node_modules/.babel-runtime.DELETE'] {
npm ERR!   cause: [Error: EACCES: permission denied, rename '/home/gareth/blog-website/services/blog/node_modules/babel-runtime' -> '/home/gareth/blog-website/services/blog/node_modules/.babel-runtime.DELETE'] {
npm ERR!     errno: -13,
npm ERR!     code: 'EACCES',
npm ERR!     syscall: 'rename',
npm ERR!     path: '/home/gareth/blog-website/services/blog/node_modules/babel-runtime',
npm ERR!     dest: '/home/gareth/blog-website/services/blog/node_modules/.babel-runtime.DELETE'
npm ERR!   },
npm ERR!   stack: "Error: EACCES: permission denied, rename '/home/gareth/blog-website/services/blog/node_modules/babel-runtime' -> '/home/gareth/blog-website/services/blog/node_modules/.babel-runtime.DELETE'",
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'rename',
npm ERR!   path: '/home/gareth/blog-website/services/blog/node_modules/babel-runtime',
npm ERR!   dest: '/home/gareth/blog-website/services/blog/node_modules/.babel-runtime.DELETE',
npm ERR!   parent: 'blog'
npm ERR! }
npm ERR! 
npm ERR! The operation was rejected by your operating system.
npm ERR! It is likely you do not have the permissions to access this file as the current user
npm ERR! 
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/gareth/.npm/_logs/2020-03-01T11_19_51_193Z-debug.log

 ERROR 

Command failed with exit code 243: npm install



  Error: Command failed with exit code 243: npm install
  
  - error.js:56 makeError
    [lib]/[gatsby-cli]/[execa]/lib/error.js:56:11
  
  - index.js:114 handlePromise
    [lib]/[gatsby-cli]/[execa]/index.js:114:26
  
  - task_queues.js:97 processTicksAndRejections
    internal/process/task_queues.js:97:5

Environment

  System:
    OS: Linux 4.4 Ubuntu 18.04.4 LTS (Bionic Beaver)
    CPU: (16) x64 AMD Ryzen 7 2700X Eight-Core Processor
    Shell: 4.4.20 - /bin/bash
  Binaries:
    Node: 13.9.0 - ~/.nvm/versions/node/v13.9.0/bin/node
    Yarn: 1.22.0 - /usr/bin/yarn
    npm: 6.13.7 - ~/.nvm/versions/node/v13.9.0/bin/npm
  Languages:
    Python: 2.7.17 - /usr/bin/python
  npmGlobalPackages:
    gatsby-cli: 2.9.0

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 2
  • Comments: 23 (16 by maintainers)

Most upvoted comments

I’m running gatsby with netlify dev inside of the VS Code terminal on macOS Catalina 10.15.3. Shortly after the project starts up (usually with gatsby clean && netlify dev) I get an error like the one below and it continues creating “reduxcache” folders until I close the terminal

error Generating development JavaScript bundle failed

ENOENT: no such file or directory, open '/Users/williamfendler/Sites/xxxxxx/.cache/app.js'
failed Re-building development bundle - 0.069s
warning Error persisting state: ENOENT: no such file or directory, rename 'reduxcachem7w4vQ' -> '/Users/williamfendler/Sites/xxxxxx/.cache/redux'
Screen Shot 2020-03-02 at 6 12 08 PM

All of my work right now depends on netlify dev so I haven’t tried using gatsby develop without Netlify CLI to know if that’s part of the problem. I also haven’t tried recreating it with an example repo. Until I have a minute to do those I thought I’d chime in with a few details in case it’s helpful!

It might also be worth noting that Netlify CLI is constantly competing with Gatsby to log info to the terminal so it could also be hiding some more useful errors but I’m not sure how to surface those. Let me know if you have any questions or suggestions that could help solve this.

@garethiv Also using WSL (Ubuntu 18.04.4)

gatsby: v2.19.23 and 2.19.22 (fail with error)

I started seeing:

warn Error persisting state: EACCES: permission denied, rename '/mnt/d/Git/Tailwind/tailwind-gatsby-example/www/site/.cache/redux' ->

I downgraded my version of Gatsby (v2.19.21) and it started working.

@pvdz the explanation above by @wfendler was the same exact thing happening in WSL, so it looks like it is not contained to just WSL, since he is on a Mac.

I would never run nodejs commands through sudo, so that was not the case. I thought I should’ve ran those separately, but unfortunately, I already spent too much time chasing the error yesterday and figuring out what version was the issue.

I’m 🤞 there will not be a next time. If I do see it again, I will do one at a time to get the culprit for you.

@pvdz doing a sudo rm -rf node_modules ~/.npm public .cache and upgrading back to 2.9.23 does work for the .cache rename error