Can`t run “npm install expo-cli --global”

三世轮回 提交于 2021-01-22 03:26:11

问题


I am 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 this errors: Screen 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.

Thanks:)


回答1:


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



回答2:


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!




回答3:


You can try this command:

npm install -g expo-cli

or,

yarn global add expo-cli




回答4:


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>



回答5:


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




回答6:


npm cache clean --force

This will solve the issue




回答7:


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

This will solve the problem




回答8:


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.




回答9:


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

Did work for me indeed after trying so much.




回答10:


Follow the steps

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



回答11:


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




回答12:


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



回答13:


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




回答14:


Upgrade Node version to +10

Then do

sudo npm install expo-cli -g



回答15:


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

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



回答16:


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




回答17:


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



回答18:


re-install node.js, it works for me




回答19:


npm cache clean --force

this solved my issue

https://devblogs.microsoft.com/premier-developer/getting-started-with-node-js-angular-and-visual-studio-code/




回答20:


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



回答21:


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.




回答22:


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.




回答23:


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.




回答24:


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.




回答25:


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




回答26:


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


来源:https://stackoverflow.com/questions/53361026/cant-run-npm-install-expo-cli-global

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!