• 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

  • 相关阅读:
    gcc帮助资料搜找
    由去掉word文档中的一个GoLand复制后残留的底纹说起
    记录一些有趣网站的链接
    linux cpu调度算法发展过程
    啥叫内核线程-搜集
    了解了下啥叫cfs/bfs
    c++重载运算符两种形式的选择
    概念-乐观锁、悲观锁
    go 移位操作的简单自测-移33或65位
    Shell脚本:(delayexec)Cygwin下调用schtasks创建Windows任务计划,实现延迟或定时执行某一命令
  • 原文地址:https://www.cnblogs.com/youran-he/p/14840372.html
Copyright © 2020-2023  润新知