如何修复 Mac OSX EACCES:权限被拒绝...您无权访问此文件

How to fix on Mac OSX EACCES: permission denied...You don't have access to this file

我正在尝试使用 gatsby 模板 运行 命令 gatsby new website-public https://github.com/gatsbyjs/gatsby-starter-default 在终端 window 中创建一个新项目,但我不断收到此错误:

 gatsby new website-public https://github.com/gatsbyjs/gatsby-starter-default
Error: EACCES: permission denied, open '/Users/delilah/.config/gatsby/config.json'
You don't have access to this file.

    at Object.openSync (node:fs:585:3)
    at Object.readFileSync (node:fs:453:35)
    at Ti._i.globalConfigPath.get all [as all] (/usr/local/lib/node_modules/gatsby-cli/node_modules/create-gatsby/lib/index.js:1:155965)
    at new Ti._i.globalConfigPath (/usr/local/lib/node_modules/gatsby-cli/node_modules/create-gatsby/lib/index.js:1:155924)
    at Ti (/usr/local/lib/node_modules/gatsby-cli/node_modules/create-gatsby/lib/index.js:1:155721)
    at Object.<anonymous> (/usr/local/lib/node_modules/gatsby-cli/node_modules/create-gatsby/lib/index.js:1:486075)
    at Module._compile (node:internal/modules/cjs/loader:1095:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1147:10)
    at Module.load (node:internal/modules/cjs/loader:975:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)

我试过以下方法:

  1. sudo chown -R whoami ~/.npm
  2. sudo chown -R whoami /usr/local/lib/node_modules

但没有任何帮助,我正在使用 Mac OSX。

如果有人有什么想法,请分享。

错误消息说 /Users/delilah/.config/gatsby/config.json 是您无权访问的文件,因此您必须 chown and/or chmod 修复该文件,而不是您列出的已尝试过的路径。