【问题标题】:Error: EACCES, permission denied even after using sudo?错误:EACCES,即使使用 sudo 后权限也被拒绝?
【发布时间】:2015-02-13 01:02:36
【问题描述】:

我正在尝试设置一个 chrome 扩展程序,该扩展程序将使用检查元素功能自动保存我对我的网站所做的更改。这个想法是,您将能够对网站进行实时更改,而无需返回 ide 来保存更改并重新上传等所有内容。该扩展名为 DevTools Autosave。我一直按照本网站的说明进行操作。我正在尝试在 Mac 上安装它。

我已经安装了 node.js 和扩展。当我到达说明中讨论在终端中运行哪些命令的部分时,我尝试了在“npm install -g autosave”命令前面使用和不使用“sudo”,但我总是得到这个错误:

Error: EACCES, permission denied
    at Function.startup.resolveArgv0 (node.js:815:23)
    at startup (node.js:58:13)
    at node.js:906:3

npm ERR! autosave@1.0.3 install: `node ./scripts/install.js`
npm ERR! Exit status 8
npm ERR! 
npm ERR! Failed at the autosave@1.0.3 install script.
npm ERR! This is most likely a problem with the autosave package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node ./scripts/install.js
npm ERR! You can get their info via:
npm ERR!     npm owner ls autosave
npm ERR! There is likely additional logging output above.
npm ERR! System Darwin 14.0.0
npm ERR! command "node" "/usr/local/bin/npm" "install" "-g" "autosave"
npm ERR! cwd /Users/Brent
npm ERR! node -v v0.10.33
npm ERR! npm -v 1.4.28
npm ERR! code ELIFECYCLE
npm ERR! not ok code 0

有人知道我该如何解决这个问题吗?我找不到任何遇到此问题的人,我现在已经在几个不同的论坛上,但找不到解决方案。提前致谢。

【问题讨论】:

    标签: node.js google-chrome-extension terminal google-chrome-devtools


    【解决方案1】:

    您有两个选择:修复您的npm 设置,以便您可以使用npm -g,或者在本地安装autosave。

    要在本地安装(即在当前目录中的node_modules 中),请运行npm install autosave(不带-g)。然后你可以运行./node_modules/.bin/autosave或./node_modules/autosave/bin/autosave来启动autosave。

    修复您的npm 设置,以便您可以在没有root 权限的情况下使用-g(推荐):

    在您的主目录(假设为/Users/Brent/)中,创建一个名为.npmrc 的文件,其内容如下:

    cache = /Users/Brent/.npm/cache
    globalconfig = /Users/Brent/.npm/npmrc
    globalignorefile = /Users/Brent/.npm/npmignore
    prefix = /Users/Brent/.npm
    

    并将~/.npm/lib/node_modules 添加到您的NODE_PATH,例如通过将以下内容放入.bashrc(假设您的shell是bash)以允许找到模块,并从任何地方附加~/.npm/bintoPATHso you can run any installed binary (i.e. runautosave`):

    export NODE_PATH=$HOME/.npm/lib/node_modules
    export PATH=$PATH:$HOME/.npm/bin
    

    (对.bashrc的更改仅在您加载shell时生效,或者使用. ~/.bashrc;如果您想使用新设置而不重新加载shell,只需在当前shell中运行该行(export ...) )。

    【讨论】:

    • 非常感谢!我在推荐的方法上遇到了一些问题,但你给我的第一个方法让它工作正常!
    • @DigitalBrent 第二种方法出了什么问题?如果我的说明中有错误,我会很乐意纠正它,因为推荐的方法更好,因为您可以从任何目录使用autosave。
    • 不确定,我认为问题出在您的说明上。他们看起来很清楚,但是我更新文件后仍然无法运行自动保存,所以我只是尝试了第一种方法并且有效。很可能是我自己的无能导致了这个问题。
    • @DigitalBrent 如果您想让autosave 工作,请将~/.npm/bin 添加到您的路径中。
    【解决方案2】:

    截至 2020 年,here 是 npm 推荐的解决方案。它对我有用(OSX)。 (无需更改任何路径配置或.bashrc)

    步骤:

    1. Install nvm 通过以下命令运行。

    如果您使用的是 bash

    curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.2/install.sh | bash
    

    如果您使用的是 zsh

    curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.2/install.sh | zsh
    
    1. Install node using nvm(无需卸载现有节点/npm)

    nvm install 12.13.1

    【讨论】:

      猜你喜欢
      • 2016-11-12
      • 2022-01-01
      • 2016-11-14
      • 2017-03-01
      • 2021-07-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-10-28
      相关资源
      最近更新 更多