Javascript 'expo' 不被识别为内部或外部命令

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/52731872/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-23 05:00:55  来源:igfitidea点击:

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

javascriptiosreact-nativeexpo

提问by jf___

After running npm install -g expo-cliand successfully installing the packages globally, expois still not recognized as an internal or external command. Does anyone know how I might get around this issue using windows 10, or what to do in terms of something like a path variable.

npm install -g expo-cli全局运行并成功安装软件包后,expo仍然无法识别为内部或外部命令。有谁知道我如何使用 Windows 10 解决这个问题,或者在诸如路径变量之类的方面做什么。

回答by Rocío García Luque

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

对于 Windows 10,您只需将 npm 文件夹添加到您的路径环境变量中即可。

  1. Hit Windows key and search for Environment variables.
  2. Inside the Pathvariable under System variables, add a new entry with this content (without /node_modules):
  1. 按 Windows 键并搜索Environment variables.
  2. Path变量下System variables,添加具有此内容的新条目不带 /node_modules

%USERPROFILE%\AppData\Roaming\npm

%USERPROFILE%\AppData\Roaming\npm

  1. Open a new command prompt and enter
  1. 打开一个新的命令提示符并输入

> expo

> expo

You will see something like this: enter image description here

你会看到这样的事情: 在此处输入图片说明

回答by Ruby

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

我可能来不及回答这个问题,但对于寻找相同错误的人来说,这对我有用。

  1. Install yarnif 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 yarnalso works.

  2. Use yarnto install expowith yarn global add expo-cli.

  3. expo startshould work now. yarn startand npm startshould also work.

  1. yarn如果没有,请安装。我使用了命令choco install yarn(你必须安装 Chocolatey)。如果您安装了勺子,scoop install yarn也可以使用。

  2. 使用yarn安装expoyarn global add expo-cli

  3. expo start现在应该工作。yarn startnpm start应该工作。

Hope that helps!

希望有帮助!

回答by Abu Bakr

Added These path of npm like this i have the same issue i fix it by adding the path to environment system

像这样添加了这些 npm 路径我有同样的问题我通过添加环境系统的路径来修复它

C:\Users\abobakr\AppData\Roaming\npm

After that close CMD and open it again it should work believe me

在那之后关闭 CMD 并再次打开它应该工作相信我

回答by Tenzin Kunkyab

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

昨晚我遇到了同样的问题,最近我开始了 ReactNative 的旅程。所以,那里可能有更好的答案。

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

如果您正在关注 ReactNative 官方文档,第一次 npm start 工作正常,后续会抛出错误expo,提示无法识别。我通过运行expo start而不是npm start(这基本上是同一件事,但由于某种原因不起作用)解决了这个问题。

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

所以,我的看起来像是一种解决方法,而不是解释为什么会发生这种情况或如何永久修复它。

回答by Hamza Ahmed Jameel

This worked for me:

这对我有用:

  1. You must uninstall node js then install it again.
  2. You must run npm install expo-cli.
  1. 您必须卸载 node js 然后重新安装它。
  2. 您必须运行 npm install expo-cli。

It will solve your problem

它会解决你的问题

回答by Bukunmi

For me, i uninstalled node.js,

对我来说,我卸载了 node.js,

i re-installed node.js,

我重新安装了 node.js,

i ran npm install -g expo-cli,

我跑了npm install -g expo-cli

then ran expo --version (the expo command began to work).

然后运行 ​​expo --version (expo 命令开始工作)。

Hope this helps.

希望这可以帮助。

回答by Manthano

If it still doesnt work or you can't access npm. Try setting the path with the Windows PowerShell:

如果它仍然不起作用或者您无法访问 npm。尝试使用 Windows PowerShell 设置路径:

  1. Open Windows Powershell as Administrator
  2. Type: setx path "%path%;C:\Users\USERNAME\AppData\Roaming\npm"
  1. 以管理员身份打开 Windows Powershell
  2. 类型: setx path "%path%;C:\Users\USERNAME\AppData\Roaming\npm"

It worked for me.

它对我有用。

回答by viknesh

uninstall expo using this command npm -g uninstall expo-cli --saveand reinstall expo using this command npm install -g expo-clithen it will work properly

使用此命令卸载 expo 并使用此命令 npm -g uninstall expo-cli --save重新安装 expo npm install -g expo-cli然后它将正常工作

回答by Badri Paudel

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.

昨晚我第一次安装并运行“react-native”项目时,我想知道它是否正常工作,但第二天它向我显示了与您相同的错误。

Here is what I did in windows 10 Operating System:

这是我在Windows 10 操作系统中所做的:

Addthe following path:

添加以下路径

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

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

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

现在我在CMD中一一运行了以下命令:

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

一世) npm -g uninstall expo-cli --save

ii) npm install -g expo-cli

ii) npm install -g expo-cli

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

现在启动项目并运行npm start,现在它对我有用。

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

我没有尝试这篇文章,但它也显示了相同问题的解决方案, 请参见此处

回答by Sohail Yasmin

I have fixed this in Windows 10 by setting Path C:\Users\[USERNAME] this line save my hrs

我在 Windows 10 中通过设置路径 C:\Users\[USERNAME] 这一行来解决这个问题,保存我的时间