zoukankan      html  css  js  c++  java
  • gyp ERR! stack Error: EACCES: permission denied, mkdir '/app/.jenkins/workspace/aibox-eye-manage/node_modules/node-sass/.node-gyp'

    #问题说明

    我在npm install和npm run build的时候使用的是root用户,在npm install安装依赖时报错,提示安装node-sass失败。

    #npm install报错

    gyp ERR! configure error
    gyp ERR! stack Error: EACCES: permission denied, mkdir '/app/.jenkins/workspace/aibox-eye-manage/node_modules/node-sass/.node-gyp'
    gyp ERR! System Linux 3.10.0-1160.15.2.el7.x86_64
    gyp ERR! command "/usr/local/src/node-v12.21.0-linux-x64/bin/node" "/app/.jenkins/workspace/aibox-eye-manage/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
    gyp ERR! cwd /app/.jenkins/workspace/aibox-eye-manage/node_modules/node-sass
    gyp ERR! node -v v12.21.0
    gyp ERR! node-gyp -v v3.8.0
    gyp ERR! not ok
    Build failed with error code: 1
    npm ERR! code ELIFECYCLE
    npm ERR! errno 1
    npm ERR! node-sass@4.14.1 postinstall: `node scripts/build.js`
    npm ERR! Exit status 1
    npm ERR!
    npm ERR! Failed at the node-sass@4.14.1 postinstall script.
    npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

    npm ERR! A complete log of this run can be found in:

    #问题原因

    主要还是权限问题,就是说 npm 出于安全考虑不支持以 root 用户运行,即使你用 root 用户身份运行了,npm 会自动转成一个叫 nobody 的用户来运行,而这个用户几乎没有任何权限。这样的话如果你脚本里有一些需要权限的操作,比如写文件(尤其是写 /root/.node-gyp),就会崩掉了。

    为了避免这种情况,要么按照 npm 的规矩来,专门建一个用于运行 npm 的高权限用户;要么加 --unsafe-perm 参数,这样就不会切换到 nobody 上,运行时是哪个用户就是哪个用户,即是 root。

    #问题解决

    npm rebuild node-sass --unsafe-perm

    npm insall

    npm run build

  • 相关阅读:
    java Object 类 与 Wrapper包装类
    java == 和equals()
    CPPU OJ | 开发日志
    第十八次CSP认证游记 | 2019.12.15
    CTF入门 |“男神”背后的隐写术
    Luogu2422 | 良好的感觉 (单调栈)
    Luogu4316 | 绿豆蛙的归宿 (期望DP)
    简单电路中的逻辑学(一)
    UVA12124 | Assemble (二分)
    这里是一些常用的工具网站
  • 原文地址:https://www.cnblogs.com/Leonardo-li/p/14962471.html
Copyright © 2011-2022 走看看