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

  • 相关阅读:
    [图论分块] HDU 4858 项目管理
    pytorch 自定义权重变量初始化
    Linux系统下命令静默安装weblogic12c
    第六章 类文件结构(2)
    第六章 类文件结构(1)
    第三章 垃圾收集器与内存分配策略
    第二章(3)实战: OutOfMemoryError异常
    第二章(2)HotSpot虚拟机对象探秘
    第二章(1) Java内存区域与内存溢出异常
    第一章 走进java
  • 原文地址:https://www.cnblogs.com/youran-he/p/14840372.html
Copyright © 2011-2022 走看看