首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何修复EACCES:权限被拒绝,打开‘/用户/.安装gatsby-cli时

如何修复EACCES:权限被拒绝,打开‘/用户/.安装gatsby-cli时
EN

Stack Overflow用户
提问于 2019-03-31 05:43:51
回答 2查看 7.1K关注 0票数 1

我在陷害盖茨比一开始就被困住了。当我在终端-alemkahrobek:~ alemkahrobek$ npm安装-g gatsby-cli中编写npx/npm安装全局gatsby-cli时,我看到如下内容:

/usr/local/bin/gatsby /usr/local/lib/node_modules/gatsby-cli/lib/index.js ->

gatsby遥测@1.0.4后安装/usr/local/lib/node_modules/gatsby-cli/node_modules/gatsby-telemetry节点src/postinstall.js

  • gatsby@2.5.4在13.617中增加了来自131个贡献者的225个软件包。

如果我查看盖茨比的版本,我会得到以下信息:

代码语言:javascript
复制
Alems-MacBook-Pro:~ alemkahrobek$ gatsby -v
/usr/local/lib/node_modules/gatsby-cli/node_modules/configstore/index.js:49
            throw error;
            ^

Error: EACCES: permission denied, open '/Users/alemkahrobek/.config/gatsby/config.json'
You don't have access to this file.

    at Object.openSync (fs.js:439:3)
    at Object.readFileSync (fs.js:344:35)
    at Configstore.get all [as all] (/usr/local/lib/node_modules/gatsby-cli/node_modules/configstore/index.js:31:25)
    at new Configstore (/usr/local/lib/node_modules/gatsby-cli/node_modules/configstore/index.js:25:48)
    at new Store (/usr/local/lib/node_modules/gatsby-cli/node_modules/gatsby-telemetry/lib/store.js:28:51)
    at new EventStorage (/usr/local/lib/node_modules/gatsby-cli/node_modules/gatsby-telemetry/lib/event-storage.js:24:50)
    at new AnalyticsTracker (/usr/local/lib/node_modules/gatsby-cli/node_modules/gatsby-telemetry/lib/telemetry.js:32:50)
    at Object.<anonymous> (/usr/local/lib/node_modules/gatsby-cli/node_modules/gatsby-telemetry/lib/index.js:7:18)
    at Module._compile (internal/modules/cjs/loader.js:689:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10).

现在,如果我想做一个新的项目,比如:

代码语言:javascript
复制
gatsby new example

我明白了:

代码语言:javascript
复制
Alems-MacBook-Pro:~ alemkahrobek$ npm gatsby new example


Usage: npm <command>


where <command> is one of:

access, adduser, audit, bin, bugs, c, cache, ci, cit,

clean-install, clean-install-test, completion, config,

create, ddp, dedupe, deprecate, dist-tag, docs, doctor,

edit, explore, get, help, help-search, hook, i, init,

install, install-ci-test, install-test, it, link, list, ln,

login, logout, ls, org, outdated, owner, pack, ping, prefix,

profile, prune, publish, rb, rebuild, repo, restart, root,

run, run-script, s, se, search, set, shrinkwrap, star,

stars, start, stop, t, team, test, token, tst, un,

uninstall, unpublish, unstar, up, update, v, version, view,

whoami


npm <command> -h quick help on <command>

npm -l display full usage info

npm help <term> search for help on <term>

npm help npm involved overview


Specify configs in the ini-formatted file:

/Users/alemkahrobek/.npmrc

or on the command line via: npm <command> --key value

Config info can be viewed via: npm help config



npm@6.9.0 /usr/local/lib/node_modules/npm


Alems-MacBook-Pro:~ alemkahrobek$ npm help config


NPM-CONFIG(1) NPM-CONFIG(1)


NAME

npm-config - Manage the npm configuration files


SYNOPSIS

npm config set <key> <value> [-g|--global]

npm config get <key>

npm config delete <key>

npm config list [-l] [--json]

npm config edit

npm get <key>

npm set <key> <value> [-g|--global]


aliases: c


DESCRIPTION

npm gets its config settings from the command line, environment vari-

ables, npmrc files, and in some cases, the package.json file.


See npm help 5 npmrc for more information about the npmrc files.


See npm help 7 npm-config for a more thorough discussion of the mechanisms involved.

The npm config command can be used to update and edit the contents of

the user and global npmrc files.


Sub-commands

Config supports the following sub-commands:


set

npm config set key value


Sets the config key to the value.


If value is omitted, then it sets it to "true".


get

npm config get key


Echo the config value to stdout.


list

npm config list


Show all the config settings. Use -l to also show defaults. Use --json

to show the settings in json format.


delete

npm config delete key


Deletes the key from all configuration files.


edit

npm config edit


Opens the config file in an editor. Use the --global flag to edit the

global config.



SEE ALSO

o npm help 5 folders


o npm help 7 config


o npm help 5 package.json


o npm help 5 npmrc
EN

回答 2

Stack Overflow用户

发布于 2020-06-02 05:17:59

对于遇到同样问题的Ubuntu用户,我已经解决了它对指定文件夹的正确权限:

代码语言:javascript
复制
chown -R $USER:$USER /home/$USER/.config/gatsby
票数 2
EN

Stack Overflow用户

发布于 2019-04-01 16:48:12

查看npmjs.com:https://docs.npmjs.com/resolving-eacces-permissions-errors-when-installing-packages-globally上的官方页面

我绝对是那一页上的第一个选择。nvm非常棒:https://github.com/creationix/nvm

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/55438233

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档