Gatsby - EACCESS:“.config/gatsby”的权限被拒绝

问题描述 投票:0回答:1

我尝试在 VPS 服务器上安装 Gatsby,其中 ROOT 用户的“.config”文件夹不可写,不幸的是,就像它是托管 VPS 服务器一样,我无权访问

SUDO

全局安装 Gatsby 可以工作(

npm i -g install [email protected]
),但是当我尝试执行 gatsby(
npx gatsby --version
)时,出现此错误:

` 错误:EACCES:权限被拒绝,mkdir '/home/clients/3592698af9bb61958cc5c43ea0d81272/.config/gatsby' 您无权访问此文件。

at Object.mkdirSync (node:fs:1386:3)
at AsyncFunction.pd.sync (/home/clients/3592698af9bb61958cc5c43ea0d81272/.npm-global/lib/node_modules/gatsby-cli/node_modules/create-gatsby/lib/index.js:1:148531)
at Id.xd.globalConfigPath.set all [as all] (/home/clients/3592698af9bb61958cc5c43ea0d81272/.npm-global/lib/node_modules/gatsby-cli/node_modules/create-gatsby/lib/index.js:1:156122)
at new Id.xd.globalConfigPath (/home/clients/3592698af9bb61958cc5c43ea0d81272/.npm-global/lib/node_modules/gatsby-cli/node_modules/create-gatsby/lib/index.js:1:155852)
at Id (/home/clients/3592698af9bb61958cc5c43ea0d81272/.npm-global/lib/node_modules/gatsby-cli/node_modules/create-gatsby/lib/index.js:1:155662)
at Object.<anonymous> (/home/clients/3592698af9bb61958cc5c43ea0d81272/.npm-global/lib/node_modules/gatsby-cli/node_modules/create-gatsby/lib/index.js:1:486943)
at Module._compile (node:internal/modules/cjs/loader:1126:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1180:10)
at Module.load (node:internal/modules/cjs/loader:1004:32)
at Function.Module._load (node:internal/modules/cjs/loader:839:12)

`

我的问题是,你知道如何更改 gatsby 配置文件夹的配置路径吗

/home/clients/3592698af9bb61958cc5c43ea0d81272/.npm_config/.config/gatsby
而不是
/home/clients/3592698af9bb61958cc5c43ea0d81272/.config/gatsby

我猜 Gatsby 可能从 NPM 获取了一个配置变量,但我不知道是哪一个。

提前致谢=)

** 我已经尝试过的:**

在 Gatsby 配置中,如果您遇到权限问题,有一些解决问题的链接: https://docs.npmjs.com/resolving-eacces-permissions-errors-when-installing-packages-globally https://github.com/sindresorhus/guides/blob/main/npm-global-without-sudo.md

我尝试过,但它是为了修复 npm -g install 问题,并且它不会更改 Gatsby 配置路径。

reactjs npm gatsby
1个回答
0
投票

没有 4.1.25 版本的

gatsby-cli
软件包,这可能是问题的一部分。如果您运行以下命令,您应该会看到一条错误消息:

npm install [email protected]
npm ERR! code ETARGET
npm ERR! notarget No matching version found for [email protected].
npm ERR! notarget In most cases you or one of your dependencies are requesting
npm ERR! notarget a package version that doesn't exist.

尝试不指定版本。

npm install gatsby-cli

这将在当前工作目录的

gatsby-cli
下安装最新版本的
node_modules

然后您应该能够使用

npx gatsby
运行它。

查看这篇文章,了解安装 Gatsby 的各种方法。

© www.soinside.com 2019 - 2024. All rights reserved.