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

  • 相关阅读:
    Redis基本数据类型与持久化
    Jpa创建筛选器自动忽略nul值进行搜索
    layui单元格换行
    form多个name相同表单处理
    layui合并单元格
    关于jpa example使用
    mui下拉菜单
    img在div中居中
    高德地图定位api使用
    【剑指offer】20.表示数值的字符串
  • 原文地址:https://www.cnblogs.com/Leonardo-li/p/14962471.html
Copyright © 2011-2022 走看看