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

  • 相关阅读:
    python中装饰器使用
    python文件读取操作、序列化
    Xshell使用教程
    Hadoop基础(三):基于Ubuntu16搭建Hadoop运行环境搭建
    UBUNTU的默认root密码是多少,修改root密码
    Ubuntu16.04设置静态ip
    Scala 基础(十六):泛型、类型约束-上界(Upper Bounds)/下界(lower bounds)、视图界定(View bounds)、上下文界定(Context bounds)、协变、逆变和不变
    物联网初探
    电脑不能安装虚拟机--解决办法
    vbox虚拟机和vm虚拟机 虚拟机网络不通的解决方法
  • 原文地址:https://www.cnblogs.com/youran-he/p/14840372.html
Copyright © 2011-2022 走看看