zoukankan      html  css  js  c++  java
  • npm install 安装时候报权限错误 ERR! sharp EACCES: permission denied, mkdir '/root/.npm/_libvips'

    [root@iZ2zebmri8fdr53gafp1dwZ agv]# npm install

    > sharp@0.26.2 install /home/agv/node_modules/sharp
    > (node install/libvips && node install/dll-copy && prebuild-install) || (node-gyp rebuild && node install/dll-copy)

    ERR! sharp EACCES: permission denied, mkdir '/root/.npm/_libvips'
    info sharp Are you trying to install as a root or sudo user? Try again with the --unsafe-perm flag
    info sharp Attempting to build from source via node-gyp but this may fail due to the above error
    info sharp Please see https://sharp.pixelplumbing.com/install for required dependencies
    gyp WARN EACCES current user does not have permission to access the dev dir "/root/.cache/node-gyp/14.17.0"
    gyp WARN EACCES attempting to reinstall using temporary dev dir "/home/agv/node_modules/sharp/.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 '/home/agv/node_modules/sharp/.node-gyp'
    gyp ERR! System Linux 3.10.0-1160.24.1.el7.x86_64
    gyp ERR! command "/usr/local/src/nodejs/bin/node" "/usr/local/src/nodejs/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
    gyp ERR! cwd /home/agv/node_modules/sharp
    gyp ERR! node -v v14.17.0
    gyp ERR! node-gyp -v v5.1.0
    gyp ERR! not ok
    npm WARN @zeit/next-less@1.0.1 requires a peer of less@^2.7.3 but none is installed. You must install peer dependencies yourself.
    npm WARN rc-picker@1.4.9 requires a peer of dayjs@^1.8.18 but none is installed. You must install peer dependencies yourself.
    npm WARN use-subscription@1.5.0 requires a peer of react@^17.0.0 but none is installed. You must install peer dependencies yourself.
    npm WARN agv@1.0.0 No repository field.
    npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.1.3 (node_modules/fsevents):
    npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.1.3: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
    npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.13 (node_modules/watchpack-chokidar2/node_modules/fsevents):
    npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
    npm WARN optional SKIPPING OPTIONAL DEPENDENCY: sharp@0.26.2 (node_modules/sharp):
    npm WARN optional SKIPPING OPTIONAL DEPENDENCY: sharp@0.26.2 install: `(node install/libvips && node install/dll-copy && prebuild-install) || (node-gyp rebuild && node install/dll-copy)`
    npm WARN optional SKIPPING OPTIONAL DEPENDENCY: Exit status 1

    audited 1607 packages in 8.89s

    78 packages are looking for funding
      run `npm fund` for details

    解决方案:官方提供得解决方案:https://docs.npmjs.com/resolving-eacces-permissions-errors-when-installing-packages-globally

    删除现有已安装得文件
    [root@iZ2zebmri8fdr53gafp1dwZ agv]# rm -rf node_modules/
    [root@iZ2zebmri8fdr53gafp1dwZ agv]# cd ~
    [root@iZ2zebmri8fdr53gafp1dwZ ~]# mkdir ~/.npm-global
    [root@iZ2zebmri8fdr53gafp1dwZ ~]# npm config set prefix '~/.npm-global'
    [root@iZ2zebmri8fdr53gafp1dwZ ~]# nano ~/.profile

    编辑文件

    export PATH=~/.npm-global/bin:$PATH


    [root@iZ2zebmri8fdr53gafp1dwZ ~]# source ~/.profile

    测试
    [root@iZ2zebmri8fdr53gafp1dwZ ~]# npm install -g jshint
    /root/.npm-global/bin/jshint -> /root/.npm-global/lib/node_modules/jshint/bin/jshint
    + jshint@2.13.0
    added 31 packages from 15 contributors in 8.904s

  • 相关阅读:
    JAVA 基础 / 第二十三课: 类和对象 / 什么是JAVA中的方法重载? 构造方法?
    JAVA 基础 / 第二十二课: 类和对象 / 什么是JAVA中的引用? 继承 ?
    【Oracle】ORA-12518, TNS:listener could not hand off client connection
    Oracle 将当前系统时间戳插入timestamp字段 无效的月份
    Git本地有未提交文件,直接拉取远端最新版本
    Windows下分布式环境搭建以及简单测试
    Python——pip快速下载第三方库到指定环境
    Python——Scrapy爬取链家网站所有房源信息
    Python——XPath提取某个标签下所有文本
    Python——全国瓜子二手车数据分析
  • 原文地址:https://www.cnblogs.com/youran-he/p/14840372.html
Copyright © 2011-2022 走看看