最新消息:20210816 当前crifan.com域名已被污染,为防止失联,请关注(页面右下角的)公众号

【已解决】npm安装yarn react-native-cli时出错:npm ERR Error EACCES permission denied

Web crifan 7073浏览 0评论

折腾:

【记录】折腾React Native iOS

期间,

➜  ~ npm install -g yarn react-native-cli
npm ERR! tar.unpack untar error /Users/crifan/.npm/yarn/0.21.3/package.tgz
npm ERR! tar.unpack untar error /Users/crifan/.npm/react-native-cli/2.0.1/package.tgz
npm ERR! Darwin 16.4.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "-g" "yarn" "react-native-cli"
npm ERR! node v4.4.7
npm ERR! npm  v2.15.8
npm ERR! path /usr/local/lib/node_modules/yarn
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall mkdir
npm ERR! Error: EACCES: permission denied, mkdir ‘/usr/local/lib/node_modules/yarn’
npm ERR!     at Error (native)
npm ERR!  { [Error: EACCES: permission denied, mkdir ‘/usr/local/lib/node_modules/yarn’]
npm ERR!   errno: -13,
npm ERR!   code: ‘EACCES’,
npm ERR!   syscall: ‘mkdir’,
npm ERR!   path: ‘/usr/local/lib/node_modules/yarn’,
npm ERR!   fstream_type: ‘Directory’,
npm ERR!   fstream_path: ‘/usr/local/lib/node_modules/yarn’,
npm ERR!   fstream_class: ‘DirWriter’,
npm ERR!   fstream_stack:
npm ERR!    [ ‘/usr/local/lib/node_modules/npm/node_modules/fstream/lib/dir-writer.js:35:25’,
npm ERR!      ‘/usr/local/lib/node_modules/npm/node_modules/mkdirp/index.js:47:53’,
npm ERR!      ‘FSReqWrap.oncomplete (fs.js:82:15)’ ] }
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/crifan/npm-debug.log
➜  ~

 

参考文档去:

sudo chown -R `whoami` /usr/local

就可以继续了:

➜  ~ npm install -g yarn react-native-cli
/usr/local/bin/react-native -> /usr/local/lib/node_modules/react-native-cli/index.js
/usr/local/bin/yarn -> /usr/local/lib/node_modules/yarn/bin/yarn.js
/usr/local/bin/yarnpkg -> /usr/local/lib/node_modules/yarn/bin/yarn.js
[email protected] /usr/local/lib/node_modules/react-native-cli
[email protected] /usr/local/lib/node_modules/yarn

【总结】

此处,安装React Native期间:

npm install -g yarn react-native-cli

出现错误:

npm ERR! Error: EACCES: permission denied

原因是没有访问权限。

解决办法:

sudo chown -R `whoami` /usr/local

再重新安装,即可。

转载请注明:在路上 » 【已解决】npm安装yarn react-native-cli时出错:npm ERR Error EACCES permission denied

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
88 queries in 0.198 seconds, using 22.25MB memory