【问题标题】:How to fix on Mac OSX EACCES: permission denied...You don't have access to this file如何在 Mac OSX EACCES 上修复:权限被拒绝...您无权访问此文件
【发布时间】:2022-01-04 12:33:48
【问题描述】:

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

 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。

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

【问题讨论】:

    标签: macos npm permissions sudo


    【解决方案1】:

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

    【讨论】:

    • 有什么办法解决这个问题吗?谢谢
    • “有什么办法解决这个问题吗?”是的,它就在答案中。您必须 chown 和/或 chmod 文件,以便您可以访问它。在您的问题中,您提到了 chown 和 chmod,但您在错误的路径上运行它。
    猜你喜欢
    • 2016-01-31
    • 2021-11-24
    • 2020-06-03
    • 2014-05-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-12-28
    • 2015-07-20
    相关资源
    最近更新 更多