zoukankan      html  css  js  c++  java
  • mac下载wepy报错解决方案

    今天下载wepy-cli的时候报错了

    sudo npm i wepy-cli -g 

    gyp ERR! configure error
    gyp ERR! stack Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/wepy-cli/node_modules/fsevents/.node-gyp'
    gyp ERR! System Darwin 19.2.0
    gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "configure" "--fallback-to-build" "--module=/usr/local/lib/node_modules/wepy-cli/node_modules/fsevents/lib/binding/Release/node-v72-darwin-x64/fse.node" "--module_name=fse" "--module_path=/usr/local/lib/node_modules/wepy-cli/node_modules/fsevents/lib/binding/Release/node-v72-darwin-x64" "--napi_version=5" "--node_abi_napi=napi" "--napi_build_version=0" "--node_napi_label=node-v72"
    gyp ERR! cwd /usr/local/lib/node_modules/wepy-cli/node_modules/fsevents
    gyp ERR! node -v v12.13.1
    gyp ERR! node-gyp -v v5.0.5
    gyp ERR! not ok
    node-pre-gyp ERR! build error
    node-pre-gyp ERR! stack Error: Failed to execute '/usr/local/bin/node /usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --module=/usr/local/lib/node_modules/wepy-cli/node_modules/fsevents/lib/binding/Release/node-v72-darwin-x64/fse.node --module_name=fse --module_path=/usr/local/lib/node_modules/wepy-cli/node_modules/fsevents/lib/binding/Release/node-v72-darwin-x64 --napi_version=5 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v72' (1)
    node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (/usr/local/lib/node_modules/wepy-cli/node_modules/fsevents/node_modules/node-pre-gyp/lib/util/compile.js:83:29)
    node-pre-gyp ERR! stack     at ChildProcess.emit (events.js:210:5)
    node-pre-gyp ERR! stack     at maybeClose (internal/child_process.js:1021:16)
    

    说没有权限,怎么会,我加sudo了呀。

    折腾了半天查到一个命令

    sudo npm install --unsafe-perm -g wepy-cli

    这样就可以了。

    为什么呢?

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

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

  • 相关阅读:
    使用Spring Cloud Feign作为HTTP客户端调用远程HTTP服务
    聊聊高并发系统之限流特技
    Java程序员 必须掌握的 20+ 种 Spring 常用注解
    这20个核心技术,作为Java开发程序员,你一定要掌握
    40K刚面完Java岗,这些技术必须掌握
    Java 5,6,7,8,9,10,11新特性超详细总结
    小米程序员的忧虑:感觉互联网这两年要凉,想回家种地
    Java技术文档—Java中的运算符有哪些?
    Java笔记之数组,异常处理,集合知识要点
    Java学习笔记——IO流基础知识点整理
  • 原文地址:https://www.cnblogs.com/famensaodiseng/p/11962139.html
Copyright © 2011-2022 走看看