Error executing expo commands in powershell

I'm risking in React Native and it happens that when I try to run the command expo init, or even expo --version through PowerShell it is giving the following error:

expo : 
  O arquivo C:\Users\Lucas\AppData\Roaming\npm\expo.ps1 não pode ser carregado. 
  O arquivo
C:\Users\Lucas\AppData\Roaming\npm\expo.ps1 não está assinado digitalmente.
  Não é possível executar este script no sistema atual. 
  Para obter mais informações sobre como executar scripts e definir a 
   política de execução, consulte about_Execution_Policies at
   https://go.microsoft.com/fwlink/?LinkID=135170.

No linha:1 caractere:1
+ expo --version
+ ~~~~
    + CategoryInfo          : ErrodeSegurança: (:) [], PSSecurityException
    + FullyQualifiedErrorId : UnauthorizedAccess

It turns out that by the old cmd the command is executed, and through some queries here and there I found out how to change the script protection policies, then I changed to bypass and it executes, but I believe that I leave my computer vulnerable, so I ask: How do I add expo as an exception so that it can be executed, because even with AllSigned it does not respond to commands!

* Excuse me, my first time in the community and starting in this wonderful art that is to be a programmer!

Author: Icaro Martins, 2020-10-27

1 answers

Hello I had the same problem and the solution found easily was to change the execution policy but as you said correctly leaves the computer vulnerable. The solution I found was to use npm start instead of expo start, of course since expo is installed and works perfectly the PowerShell log looked like this:

PS C:\Users\super\multiInstagram > npm start

@ start C:\Users\super\multiInstagram expo start

Starting project at C:\Users\super\multiInstagram Expo DevTools is running at http://localhost:19002 Opening DevTools in the browser... (press shift-d to disable) Starting Metro Bundler

Exp: / / 192.168.0.100: 19000

You can refer to the Expo documentation at the link below, in the item Starting the development server:

When you run expo start (or npm start), Expo CLI starts Metro Bundler, which is an HTTP server that compiles the JavaScript code of our app using Babel and serves it to the Expo app. It also pops up Expo Dev Tools, a graphical interface for Expo CLI.

Source: https://docs.expo.io/get-started/create-a-new-app/#starting-the-development-server

 0
Author: Sergio Guerjik, 2021-01-09 12:56:33