【问题标题】:I want to install mechanic on npm, I tried to run this line sudo npm install -g mechanic, but it gives me error, I don't understand this error我想在 npm 上安装 mechanic,我尝试运行这一行 sudo npm install -g mechanic,但它给了我错误,我不明白这个错误
【发布时间】:2020-09-10 21:58:32
【问题描述】:

我想在我的 nginx 服务器上安装 mechanic。

执行sudo npm install -g mechanic时出现此错误:

tigaron@galaxybrainpower:/var/www/tigaron$ sudo npm install -g mechanic
/usr/bin/mechanic -> /usr/lib/node_modules/mechanic/bin/mechanic

> fs-ext@2.0.0 install /usr/lib/node_modules/mechanic/node_modules/fs-ext
> node-gyp configure build

gyp WARN EACCES current user ("nobody") does not have permission to access the dev dir "/home/tigaron/.cache/node-gyp/10.20.1"
gyp WARN EACCES attempting to reinstall using temporary dev dir "/usr/lib/node_modules/mechanic/node_modules/fs-ext/.node-gyp"
gyp WARN install got an error, rolling back install
gyp WARN install got an error, rolling back install
gyp ERR! configure error 
gyp ERR! stack Error: EACCES: permission denied, mkdir '/usr/lib/node_modules/mechanic/node_modules/fs-ext/.node-gyp'
gyp ERR! System Linux 4.15.0
gyp ERR! command "/usr/bin/node" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "configure" "build"
gyp ERR! cwd /usr/lib/node_modules/mechanic/node_modules/fs-ext
gyp ERR! node -v v10.20.1
gyp ERR! node-gyp -v v5.1.0
gyp ERR! not ok 
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! fs-ext@2.0.0 install: `node-gyp configure build`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the fs-ext@2.0.0 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/tigaron/.npm/_logs/2020-05-24T06_29_26_857Z-debug.log

这里发生了什么?如何修复此错误并继续安装?

【问题讨论】:

    标签: node.js linux nginx npm


    【解决方案1】:

    This answer 解决了我在安装不同软件包时遇到的同样问题。

    显然nobody 用户在全局构建包时使用,但目录归root 所有,因此权限失败。答案建议使用以下命令配置npm 以使用root

    npm -g config set user root
    

    【讨论】:

      猜你喜欢
      • 2021-08-10
      • 2013-09-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-11-12
      • 2021-11-29
      • 2022-12-21
      • 2021-08-02
      相关资源
      最近更新 更多