Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

did i install create-react-app incorrectly?

Tags:

macos

reactjs

I want to try React on my Mac, but I face some difficulties when using it.

  1. I installed create-react-app globally with

    npm install -g create-react-app

But everytime I create a new project I have a huge node_modules folder in my project folder. AFAIK I don't need node_modules folder in every project if create-react-app installed globally. So what's the problem?

  1. When I tried to uninstall create-react-app to install it again (just to be sure I installed it globally) I get an error saying

    npm remove -g create-react-app

    Error: EACCES: permission denied, unlink 'usr/local/bin/create-react-app'

So what do I do in this case?

like image 228
AndSolomin34 Avatar asked Dec 23 '22 00:12

AndSolomin34


2 Answers

  1. The node_modules folder you see for every project is node_modules for that specific project. This is how all javascript projects that use npm work. You don't want all the dependencies of every project installed globally. That would run into all kinds of issues with different versions of packages etc.
  2. This error indicates that you probably ran npm install -g create-react-app as either root or as sudo like so: sudo npm install -g create-react-app. Try running sudo npm remove -g create-react-app and see if that works.
like image 92
Marius Avatar answered Jan 12 '23 09:01

Marius


I couldn't use the new version of create-react-app with npx, so I tried to remove via the command npm uninstall -g create-react-app. After that when I checked it still has "installed". So I have removed manually

rm -rf /usr/local/bin/create-react-app
like image 35
Gapur Kassym Avatar answered Jan 12 '23 11:01

Gapur Kassym