尖括号EACCES:CentOS/RHEL 7上的权限被拒绝 – 已修复

在安装Nodejs包时,解决EACCES权限被拒绝的错误。

在安装Nodejs包Browsertime时,我遇到了以下错误。

[root@gf-lab ~]#npm install browsertime -g
/usr/bin/browsertime -> /usr/lib/node_modules/browsertime/bin/browsertime.js

> @sitespeed.io/[email protected]安装/usr/lib/node_modules/browsertime/node_modules/@sitespeed.io/chromedriver
> 节点安装.js

(节点:26690)UnhandledPromiseRejectionWarning:错误:目标文件夹必须存在
在DownloaderHelper.__validate(/usr/lib/node_modules/browsertime/node_modules/@sitespeed.io/chromedriver/node_modules/node-downloader-helper/dist/index.js:390:23)
在新的DownloaderHelper(/usr/lib/node_modules/browsertime/node_modules/@sitespeed.io/chromedriver/node_modules/node-downloader-helper/dist/index.js:61:20)
在下载(/usr/lib/node_modules/browsertime/node_modules/@sitespeed.io/chromedriver/install.js:68:18)
(节点:26690)UnhandledPromiseRejectionWarning:未处理的承诺拒绝。此错误可能是由于在没有catch块的异步函数中抛出,或者通过未使用.catch()处理的promise拒绝引起的。(拒绝id:1)
(节点:26690)[DEP0018] DeprecationWarning:未处理的承诺拒绝已弃用。将来,未处理的promise拒绝将以非零退出代码终止Node.js进程。

> @sitespeed.io/[email protected]安装/usr/lib/node_modules/browsertime/node_modules/@sitespeed.io/geckodriver
> 节点安装.js

(节点:26701)UnhandledPromiseRejectionWarning:错误:目标文件夹必须存在
在DownloaderHelper.__validate(/usr/lib/node_modules/browsertime/node_modules/@sitespeed.io/geckodriver/node_modules/node-downloader-helper/dist/index.js:387:23)
在新的DownloaderHelper(/usr/lib/node_modules/browsertime/node_modules/@sitespeed.io/geckodriver/node_modules/node-downloader-helper/dist/index.js:61:20)
在下载(/usr/lib/node_modules/browsertime/node_modules/@sitespeed.io/geckodriver/install.js:73:18)
(节点:26701)UnhandledPromiseRejectionWarning:未处理的承诺拒绝。此错误可能是由于在没有catch块的异步函数中抛出,或者通过未使用.catch()处理的promise拒绝引起的。(拒绝id:1)
(节点:26701)[DEP0018] DeprecationWarning:未处理的承诺拒绝已弃用。将来,未处理的promise拒绝将以非零退出代码终止Node.js进程。

> [email protected]安装/usr/lib/node_modules/browsertime/node_modules/sharp
>(节点安装/ libvips &&节点安装/ dll-copy && prebuild-install)||(节点-gyp重建&&节点安装/ dll-copy)

ERR!sharp EACCES:权限被拒绝,mkdir'/root/.npm/_libvips'
info sharp尝试通过node-gyp从源代码构建,但由于上述错误可能会失败
info sharp请参阅https://sharp.pixelplumbing.com/page/install以获取所需的依赖关系
gyp WARN EACCES用户“root”没有权限访问开发目录“/root/.node-gyp/11.15.0”
gyp WARN EACCES尝试使用临时开发目录“/usr/lib/node_modules/browsertime/node_modules/sharp/.node-gyp”重新安装
gyp WARN install遇到错误,回滚安装
gyp WARN install遇到错误,回滚安装
gyp ERR!configure错误
gyp ERR!stack Error:EACCES:权限被拒绝,mkdir'/usr/lib/node_modules/browsertime/node_modules/sharp/.node-gyp'
gyp ERR!System Linux 3.10.0-957.27.2.el7.x86_64
gyp ERR!command“/usr/bin/node”“/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js”“rebuild”
gyp ERR!cwd /usr/lib/node_modules/browsertime/node_modules/sharp
gyp ERR!node -v v11.15.0
gyp ERR!node-gyp -v v3.8.0
gyp ERR!not ok
npm ERR!code ELIFECYCLE
npm ERR!errno 1
npm ERR![email protected]安装:`(node install/libvips && node install/dll-copy && prebuild-install)||(节点-gyp重建&&节点安装/ dll-copy)`
npm ERR!退出状态1
npm ERR!
npm ERR!安装脚本[email protected]失败。
npm ERR!这可能不是npm的问题。可能还有其他日志输出在上面。

npm ERR!此运行的完整日志可以在以下位置找到:

我尝试了一些方法,但都没有奏效。在进行了一小段搜索之后,我发现了 npmjs documentation并尝试了 --unsafe-perm 标记。

npm install --unsafe-perm

例如:对于我的安装。

npm install --unsafe-perm browsertime -g

它像魔术一样起作用。希望对你也有帮助。

类似文章