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:

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.

Upvotes: 14

Views: 96026

Answers (30)

MOIN MALIK
MOIN MALIK

Reputation: 1

This works for me... ubuntu 20.02 sudo npm install expo-cli -global

Upvotes: 0

andresf
andresf

Reputation: 198

I was trying to install expo-cli with my company npm registry configured. I've created 2 differents profiles using npmrc and using the profile with https://registry.npmjs.org/ solved the issue.

Upvotes: 0

jeany
jeany

Reputation: 107

Sometime, I use npm not work. I try a lots times run with npm but fail for expo cli.
Please try yarn global add expo-cli It wills save your time ^^.

Upvotes: 0

jadonlamx
jadonlamx

Reputation: 81

First: I upgraded my mac version 10.13 to 10.15

Then I downloaded homebrew, Watchman, Git and Node.js

Finally I ran this command sudo npm install --global expo-cli --legacy-peer-deps

If you have any further questions check the docs out: https://docs.expo.dev/get-started/installation/

Upvotes: 0

Faruk Suljagic
Faruk Suljagic

Reputation: 108

If anyone else has this problem here is my fix, go to Finder, in the input field (search box) type in /usr/local/lib then press CMD + SHIFT + G press the OK button or whatever pops up, then CMD + SHIFT + . and delete the NVM file i deleted the expo folder too. Then go to this link https://changelog.com/posts/install-node-js-with-homebrew-on-os-x follow the instructions and install brew, node, etc. Last step go to your terminal and type sudo npm install expo-cli --global

Upvotes: 0

Robert Yeomans
Robert Yeomans

Reputation: 376

I had previously removed Expo from my Windows machine and encountered this error whilst trying to reinstall. Reading the error message solved the problem.

npm i expo-cli -g --legacy-peer-deps

Using this command in 'PowerShell' installed expo successfully.

Upvotes: 0

sumit Panda
sumit Panda

Reputation: 1

Here is the solution and 100% working. I am working with Windows and not sure abut Linux.

Open cmd and

Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser

then press yes

Now run the command to start your project

npm install -g expo-cli

Upvotes: 0

Rahul Sapparapu
Rahul Sapparapu

Reputation: 59

I had this problem in Windows 10, to be able to install the latest version (I had no choice since it broke the current one). I had to install the latest version of Python (3.8.0) and then run npm install --global --production windows-build-tools as an administrator, then I was able to run again: npm install expo-cli --global to install the version 3.8.0 of the expo-cli

Upvotes: 0

Rohan Devaki
Rohan Devaki

Reputation: 3279

For windows Follow these steps carefully

  1. open the command prompt and run it as administrator.
  2. recommended npm uninstall --global expo-cli.
  3. run the command npm cache clean --force.
  4. run the command npm cache verify .
  5. now run the command npm install --global expo-cli
  6. dont run command like npm i -g expo-cli or npm install -g expo-cli.

7.Make sure you run the command mentioned in the 4th step ONLY.

thankyou.

Upvotes: 0

Zhivar Sourati
Zhivar Sourati

Reputation: 593

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

Upvotes: 17

Manik Verma
Manik Verma

Reputation: 241

For Windows User :-

Open your Powershell and type:

npm install expo-cli --global

This worked for me after trying and reasearching for hours.

Note:Don't Use cmd or any other terminal and also don't type npm install expo-cli -g as it is written in the react native docs. It would always show up an npm error.

Upvotes: 0

Emad Baqeri
Emad Baqeri

Reputation: 2702

As a Debian 10 buster user I got the same permission error while using this command: sudo npm install expo-cli --global. The problem was solved by installing expo-cli with yarn package manager and the command below: sudo yarn global add expo-cli.

Upvotes: 0

Nathaniel Koehler
Nathaniel Koehler

Reputation: 129

try going into windows resource monitor and terminating adb.exe (android resource bridge). This worked for me after searching for solutions for days. I tried this after verifying cache, clearing cache, you name it.

Upvotes: 0

Meet Lukka
Meet Lukka

Reputation: 73

First update Node.js to the latest stable version and then again try to install expo ad clean before expo folders that are being created in below location

C:\Users\{{computer_username}}\AppData\Roaming\npm

If it's throwing error in visual studio code, try from cmd, was facing same error but solved through this way

npm install -g expo-cli

Upvotes: 0

Mohammed Elzanaty
Mohammed Elzanaty

Reputation: 393

npm cache clean --force then npm install --unsafe-perm -g expo-cli

Upvotes: 1

Abhiram Das
Abhiram Das

Reputation: 72

npm cache clean --force

This will solve the issue

Upvotes: 3

Aditya Dirgantara
Aditya Dirgantara

Reputation: 11

re-install node.js, it works for me

Upvotes: 0

utsav
utsav

Reputation: 41

Follow the steps

  • First, run npm cache verify.
  • Open Windows PowerShell as administrator and run npm install expo-cli --global --no-optional command.

Upvotes: 2

shireef khatab
shireef khatab

Reputation: 1005

In my case, I deleted two files then everything worked. The two files are in this path: C:\Users\{Username}\AppData\Roaming\npm under the names 'expo.ps1' and 'expo-cli.ps1'

Then run:

npm i -g expo-cli

Upvotes: 0

Shrey Jain
Shrey Jain

Reputation: 93

Try using npm install -g expo-cli@3.5.0 this worked for me, it may work for you.

Upvotes: 2

Daniel Melo
Daniel Melo

Reputation: 568

If any of the solutions above result in success, please follow the steps below:

  1. Uninstall Node.js
  2. Restart your pc/mac
  3. Download latest version of the Node.js (https://nodejs.org/en/)
  4. Open cmd as admin mode or use "sudo" before the command line on Mac.

    npm install expo-cli --global

I hope it can help

Upvotes: 0

Ashley Colaco
Ashley Colaco

Reputation: 11

First run npm cache verify, then run sudo npm install --global expo-cli.

Did work for me indeed after trying so much.

Upvotes: 1

user3505838
user3505838

Reputation: 361

This worked for me. I hope this would solve your problem!

sudo npm install expo-cli -g --unsafe-perm=true --allow-root

Upvotes: 0

webmaster
webmaster

Reputation: 2020

Upgrade Node version to +10

Then do

sudo npm install expo-cli -g

Upvotes: 0

Unchained
Unchained

Reputation: 710

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>

Upvotes: 6

Yasin Farmani
Yasin Farmani

Reputation: 153

I guess, this issue comes from permission or node version , if you get this error when the node module is being refreshed ---> This is definitely a permission issue. Disable your Antiviruses or change permission manually check this as well.

Upvotes: 1

Dip
Dip

Reputation: 696

You need administrator privilege. So when you open command line interface, just right click and run as administrator

This will solve the problem

Upvotes: 1

J C
J C

Reputation: 761

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!

Upvotes: 14

molebox
molebox

Reputation: 585

You have to run the command as administrator from a command prompt on windows and not bash. Had me stumpt for bloody ages!

Upvotes: 1

Ali Hasan
Ali Hasan

Reputation: 4353

You can try this command:

npm install -g expo-cli

or,

yarn global add expo-cli

Upvotes: 1

Related Questions