npm安装create-react-app出现“Error: EACCES: permission denied”的解决办法

开发环境

mac 10.12.4、node v6.10.2、npm  v3.10.10

问题描述

使用npm命令

npm install -g create-react-app

安装create-react-app的时候出现以下错误:

npm ERR! Darwin 16.5.0

npm ERR!argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "-g" "create-react-app"

npm ERR!node v6.10.2

npm ERR!npm  v3.10.10

npm ERR!path ../lib/node_modules/create-react-app/index.js

npm ERR!code EACCES

npm ERR!errno -13

npm ERR!syscall symlink


npm ERR! Error: EACCES: permission denied, symlink '../lib/node_modules/create-react-app/index.js' -> '/usr/local/bin/create-react-app'

npm ERR!     at Error (native)

npm ERR!  { Error: EACCES: permission denied, symlink '../lib/node_modules/create-react-app/index.js' -> '/usr/local/bin/create-react-app'

npm ERR!     at Error (native)

npm ERR!   errno: -13,

npm ERR!   code: 'EACCES',

npm ERR!   syscall: 'symlink',

npm ERR!   path: '../lib/node_modules/create-react-app/index.js',

npm ERR!   dest: '/usr/local/bin/create-react-app' }

npm ERR! 

npm ERR! Please try running this command again as root/Administrator.


npm ERR! Please include the following file with any support request:

npm ERR!     /Users/wudengwei/npm-debug.log

问题原因

npm的错误提示已经指出了原因:Error: EACCES: permission denied (权限不够)

并给出了建议 

Please try running this command again as root/Administrator.(使用管理员权限)

问题解决

使用加上sudo的npm命令(sudo: 申请root 权限

sudo npm install -g create-react-app


总结

代码执行出错,都会有相应的错误提示。它或多或少交代了问题的原因,但解决方法就需要我们思考了。


  • 3
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值