7

I am installing create-react-app through terminal. I have checked the node.js version is 4.5.0, which is higher than the requirement here. and the version of npm is 2.15.9. Then I type the command npm install -g create-react-app , there came out such error information:

npm ERR! tar.unpack untar error /Users/xiufenxu/.npm/create-react-app/0.6.0/package.tgz
npm ERR! Darwin 16.0.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "-g" "create-react-app"
npm ERR! node v4.5.0
npm ERR! npm  v2.15.9
npm ERR! path /usr/local/lib/node_modules/create-react-app
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall mkdir

npm ERR! Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/create-react-app'
npm ERR!     at Error (native)
npm ERR!  { [Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/create-react-app']
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'mkdir',
npm ERR!   path: '/usr/local/lib/node_modules/create-react-app',
npm ERR!   fstream_type: 'Directory',
npm ERR!   fstream_path: '/usr/local/lib/node_modules/create-react-app',
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/xiufenxu/Documents/UM courses/Fall 2016/CSCI 5117/npm-debug.log

Why did I get such errors and how do I prevent them from occuring?

Adriaan
  • 17,741
  • 7
  • 42
  • 75
Xiufen Xu
  • 531
  • 1
  • 3
  • 19
  • See the links here: Suggested three ways of fixing it. [enter link description here](https://stackoverflow.com/questions/33725639/npm-install-g-less-does-not-work) – WPFKK Jan 06 '19 at 20:14

2 Answers2

23
sudo npm install -g create-react-app

you're running it as a user without root permissions

Conan
  • 670
  • 7
  • 12
  • Oh, I see! Thank you! Did you know this from the line `npm ERR! Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/create-react-app'`? – Xiufen Xu Nov 01 '16 at 22:45
  • see suggested answers here: https://stackoverflow.com/questions/33725639/npm-install-g-less-does-not-work – WPFKK Jan 06 '19 at 20:14
  • If the above answer didn't work, please uninstall it first `sudo npm uninstall -g create-react-app` and then the above answer will work – Vikas Acharya May 29 '21 at 13:01
0

Restarting my computer fixed it for me

kelrob-dev
  • 91
  • 1
  • 9