'expo' is not recognized as an internal or external command

后端 未结 15 955
余生分开走
余生分开走 2020-12-30 01:12

After running npm install -g expo-cli and successfully installing the packages globally, expo is still not recognized as an internal or external co

相关标签:
15条回答
  • 2020-12-30 01:38

    uninstall expo using this command npm -g uninstall expo-cli --save and reinstall expo using this command npm install -g expo-cli then it will work properly

    0 讨论(0)
  • 2020-12-30 01:39

    I may be too late to answer this, but for people looking for the same error this is what worked for me.

    1. Install yarn if you don't have it. I used the command choco install yarn (you'll have to install Chocolatey). If you have scoop installed, scoop install yarn also works.

    2. Use yarn to install expo with yarn global add expo-cli.

    3. expo start should work now. yarn start and npm start should also work.

    Hope that helps!

    0 讨论(0)
  • 2020-12-30 01:39

    I had the same problem last night, and I've recently started my journey in ReactNative. So, there might be better answers out there.

    If you're following the ReactNative Official documentation, the first time npm start works fine, the subsequent ones throws an error saying expo is not recognized. I got around that by running expo start and not npm start ( which basically is the same thing but doesn't work for some reason ).

    So, mine looks like a work around rather than an explanation as to why this happens or how to permanently fix it.

    0 讨论(0)
  • 2020-12-30 01:41

    For Windows 10, you can simply add the npm folder to your path environment variable.

    1. Hit Windows key and search for Environment variables.
    2. Inside the Path variable under System variables, add a new entry with this content (without /node_modules ):

    %USERPROFILE%\AppData\Roaming\npm

    1. Open a new command prompt and enter

    > expo

    You will see something like this:

    0 讨论(0)
  • 2020-12-30 01:43

    If you need a solution to Run Expo command without Environment Variable update then on your terminal use below command for windows system:

    R:\> C:\Users\{user}\AppData\Roaming\npm\expo.cmd init {projectname}
    

    Where you directly point the expo.cmd file rather than specifying in the environment variable.

    And update the expo to C:\Users{user}\AppData\Roaming\npm\expo.cmd in package.json to run the project.

    // package.json
    "scripts": {
        "start": "C:\\Users\\{user}\\AppData\\Roaming\\npm\\expo.cmd start",
        "android": "C:\\Users\\{user}\\AppData\\Roaming\\npm\\expo.cmd start --android",
        "ios": "C:\\Users\\{user}\\AppData\\Roaming\\npm\\expo.cmd start --ios",
        "web": "C:\\Users\\{user}\\AppData\\Roaming\\npm\\expo.cmdstart --web",
        "eject": "C:\\Users\\{user}\\AppData\\Roaming\\npm\\expo.cmd eject"
      },
    
    0 讨论(0)
  • 2020-12-30 01:46

    I wondered it was working last night when I first installed and run the "react-native" project but the very next day it showed me the same error as yours.

    Here is what I did in windows 10 Operating System:

    Add the following path :

    environment variable > System Variables > PATH > C:\Users\YOUR_USERNAME\AppData\Roaming\npm

    Now I ran the following commands one by one in CMD:

    i) npm -g uninstall expo-cli --save

    ii) npm install -g expo-cli

    Now start the Project and run npm start and now it works for me.

    I didn't try this article one but it also shows the solution for the same problem, see here

    0 讨论(0)
提交回复
热议问题