Search NITYAM TECH Blog

Sunday, February 4, 2024

Expo : cannot be loaded because running scripts is disabled on this system.

 expo : File C:\Users\HP\AppData\Roaming\npm\expo.ps1 cannot be loaded because running scripts is disabled on this system. For more information, see 

about_Execution_Policies at https:/go.microsoft.com/fwlink/?LinkID=135170.

At line:1 char:1

+ expo start

+ ~~~~

  + CategoryInfo     : SecurityError: (:) [], PSSecurityException  

  + FullyQualifiedErrorId : UnauthorizedAccess



Nayak Tech, Here to help you resolve the error preventing you from running expo start.

The error indicates that PowerShell script execution is disabled on your system, blocking Expo's PowerShell script from running.

Here's how to enable script execution:

  1. Open PowerShell as Administrator:

    • Right-click the Start button and select "Windows PowerShell (Admin)".
  2. Check Current Execution Policy:

    • Type Get-ExecutionPolicy and press Enter.
    • If it's "Restricted", you'll need to change it.
  3. Set Execution Policy to "RemoteSigned" (Recommended):

    • Type Set-ExecutionPolicy RemoteSigned and press Enter.
    • Confirm by typing "Y" and pressing Enter.
    • This allows scripts from trusted publishers to run while protecting against potentially malicious scripts.
  4. Alternative: Set Execution Policy to "Unrestricted" (Less Secure):

    • If you're certain of script safety, type Set-ExecutionPolicy Unrestricted and press Enter.
    • Use with caution, as it allows any script to run.
  5. Verify Change:

    • Type Get-ExecutionPolicy again to confirm the change.
  6. Retry Expo Command:

    • Close and reopen PowerShell (not as administrator).
    • Run expo start again. It should now execute successfully.



Important Notes:

  • If you encounter permission issues, try running PowerShell in the project directory.
  • For a more secure approach, consider creating a custom execution policy specifically for Expo scripts.
  • If you're still facing issues, provide more details about your environment and any additional error messages.

Featured Post

npx expo install @react-native-async-storage/async-storage

Understanding and Using AsyncStorage in React Native with Expo Introduction In the world of React Native, data persistence is a fundamental ...