13

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.

Penny Liu
  • 15,447
  • 5
  • 79
  • 98

31 Answers31

17

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
Zhivar Sourati
  • 503
  • 6
  • 9
  • It is worked for me. It saved my time. Thanks a lot – Vignes Nov 15 '19 at 06:12
  • the cmd npm install -g expo-cli after the updated version of npm is still not working for me, it is showing this error ```[ ......] | remove:@expo/config: sill remove C:\Users\jagan\AppData\Roaming\npm\node_modules\expo-cli\node_modules\@expo\config``` please solve this – Rohan Devaki Aug 28 '20 at 05:07
  • new error ```Installing Expo CLI failed. You can install it manually with: npm install --global expo-cli npm ERR! code ELIFECYCLE npm ERR! @ start: `expo start` npm ERR! Exit status 4294963248 npm ERR! npm ERR! Failed at the @ start script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above. npm ERR! A complete log of this run can be found in: npm ERR! C:\Users\jagan\AppData\Roaming\npm-cache\_logs\2020-08-29T06_08_01_926Z-debug.log``` – Rohan Devaki Aug 29 '20 at 06:12
13

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!

J C
  • 731
  • 7
  • 11
6

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>
Unchained
  • 677
  • 7
  • 8
3
npm cache clean --force

This will solve the issue

Durdu
  • 4,649
  • 2
  • 27
  • 47
2

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

Shrey Jain
  • 73
  • 1
  • 5
2

Follow the steps

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

You can try this command:

npm install -g expo-cli

or,

yarn global add expo-cli

Ali Hasan
  • 3,843
  • 1
  • 5
  • 9
1

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

molebox
  • 585
  • 1
  • 8
  • 17
1

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

This will solve the problem

Dip
  • 646
  • 6
  • 8
1

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.

1

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

Did work for me indeed after trying so much.

phaberest
  • 3,140
  • 3
  • 32
  • 40
1

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

  • 1
    Are you aware of the risks of using sudo with npm? Did you disclose those risks in this answer? – Jason Aller Mar 22 '20 at 02:45
  • 1
    While this post may answer the question, code-only answers are often considered low-quality. Please provide some rationale / text explanation as to why this is the correct answer, even if short. – Dan Mar 24 '20 at 08:44
0

It is likely you do not have the permissions to access this file as the current user. The best way to solve this problem is to reinstall npm with a node version manager.And you don't need to remove your current version.

About node version manager

  1. use nvm or n with OSX or Linux
  2. use nodist or nvm-windows with windows
Root
  • 2,301
  • 1
  • 10
  • 14
0

Upgrade Node version to +10

Then do

sudo npm install expo-cli -g
Zoe
  • 27,060
  • 21
  • 118
  • 148
webmaster
  • 1,960
  • 24
  • 29
0

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

sudo npm install expo-cli -g --unsafe-perm=true --allow-root
user3505838
  • 351
  • 3
  • 8
0

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

Daniel Melo
  • 548
  • 5
  • 12
0

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
halfer
  • 19,824
  • 17
  • 99
  • 186
shireef khatab
  • 977
  • 2
  • 13
  • 33
0

re-install node.js, it works for me

  • 2
    When adding an answer to a question that already has fifteen other answers it is useful to point out what aspect of the question your answer addresses that has not already been addressed. Also it is useful to explain why you think your solution will work, and how it works. – Jason Aller Mar 07 '20 at 07:16
0

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
David Buck
  • 3,752
  • 35
  • 31
  • 35
Meet Lukka
  • 63
  • 3
  • i am bot able to delete the expo-cli file in the location `C:\Users\{{computer_username}}\AppData\Roaming\npm` , it is always saying the folder is in use, even though i have closed all the folders. – Rohan Devaki Aug 29 '20 at 06:54
0

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.

0

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.

Emad Baqeri
  • 2,333
  • 2
  • 14
  • 29
0

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.

jizhihaoSAMA
  • 12,336
  • 9
  • 27
  • 49
Manik Verma
  • 161
  • 1
  • 5
0

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.

Rohan Devaki
  • 2,931
  • 1
  • 14
  • 22
0

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

0

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
Greenonline
  • 1,330
  • 8
  • 23
  • 31
0

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.

Robert Yeomans
  • 192
  • 1
  • 4
0

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

Faruk Suljagic
  • 88
  • 1
  • 1
  • 8
0

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/

Dharman
  • 30,962
  • 25
  • 85
  • 135
jadonlamx
  • 81
  • 1
  • 2
0

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 ^^.

jeany
  • 89
  • 1
  • 3
0

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.

andresf
  • 198
  • 1
  • 10
0

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

  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community May 13 '22 at 08:39