• npm install 报错,提示`gyp ERR! stack Error: EACCES: permission denied` 解决方法


    m install 报错,提示gyp ERR! stack Error: EACCES: permission denied

    猜测可能是因为没有权限读写,ls -la看下文件权限设置情况

    [root@root vendors]# ls -la
    drwxr-xr-x 307 root root  12288 Jun  5 23:08 node_modules
    -rwxr-xr-x   1 root root   5880 Jun  5 23:06 package.json
    -rw-r--r--   1 root root 900847 Jun  5 23:06 package-lock.json

    只有root用户组有读写权限,其他只读,将node_modules文件夹修改权限,再执行看看

    [root@root vendors]# npm i --production
    
    > jsonpath@1.0.2 postinstall /www/server/yapi/vendors/node_modules/jsonpath
    > node lib/aesprim.js > generated/aesprim-browser.js
    
    sh: generated/aesprim-browser.js: Permission denied
    npm WARN mongoose-auto-increment@5.0.1 requires a peer of mongoose@^4.1.12 but none is installed. You must install peer dependencies yourself.
    
    npm ERR! code ELIFECYCLE
    npm ERR! errno 1
    npm ERR! jsonpath@1.0.2 postinstall: `node lib/aesprim.js > generated/aesprim-browser.js`
    npm ERR! Exit status 1
    npm ERR! 
    npm ERR! Failed at the jsonpath@1.0.2 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 ERR!     /root/.npm/_logs/2019-06-05T15_10_22_303Z-debug.log

    经过面向搜索引擎开发,有提到用sudo,但是发现还是不行,实际原因是由于用的是root账户权限执行npm,而npm默认是不适用root权限创建内容,因此会出现权限问题而导致失败,加上参数--unsafe-perm=true --allow-root即可解决问题。

    npm install --production --unsafe-perm=true --allow-root
  • 相关阅读:
    zoj 3820 Building Fire Stations(树上乱搞)
    wxWidgets+wxSmith版电子词典
    Android异步载入全解析之IntentService
    HDU 3832 Earth Hour(最短路)
    Android 应用程序窗口显示状态操作(requestWindowFeature()的应用)
    HighChart学习-更新数据data Series与重绘
    sar使用说明
    xcode多target
    Creating Contextual Menus创建上下文菜单
    安卓开发11:操作控件
  • 原文地址:https://www.cnblogs.com/jasonLiu2018/p/11987328.html
Copyright © 2020-2023  润新知