Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't run "npm install expo-cli --global"

I am a newbie in all this stuff. Hope for your understanding.

Let me clarify the issue: I am trying to start react native app through expo cli. So tried to start npm install expo-cli --global to install npm globally. I got these errors:

  • Screen_1
  • Screen_2

It also says that I lack permissions to access it. How can I allow permissions? Even when I try to start it locally I got the same issue. Your help is appreciated.

like image 950
Jaloliddin Jaloliddinov Avatar asked Nov 18 '18 12:11

Jaloliddin Jaloliddinov


3 Answers

You did not mention which os. This answer working for any operating system (ubuntu in my case)

I'm also getting permission errors when running

sudo npm install --global expo-cli

Which I don't really how this can happen - as this also happens for the superuser!

For me it works when I install the client locally into the project

cd <new-project-dir>
npm init # init npm project
npm install expo-cli

Now you can use the client in this project like this:

npx expo-cli # e.g. npx expo-cli init <project-name>
like image 145
Unchained Avatar answered Oct 20 '22 00:10

Unchained


although this solution is not the best and the safest solution exists, this worked for me and that make sense because all the problem we had with the errors is the permission problems. so you can use this command and ignore those permission problems :

sudo npm install expo-cli -g --unsafe-perm
like image 45
Zhivar Sourati Avatar answered Oct 20 '22 01:10

Zhivar Sourati


I was having the same problem with npm install -g expo-cli, having "MODULE_NOT_FOUND",

I installed yarm with brew, just in case you do not already have it:

brew install yarn

and then use:

yarn global add expo-cli

to create a project you can:

expo init nameOfTheNewProject

and choose a template in the console. Finally run the project with

yarn start

Let me know if it works for you!

like image 22
J C Avatar answered Oct 20 '22 01:10

J C