Get me outta here!

Saturday, June 10, 2023

Run React Globally

 If you have problems running create-react-app in text editors but the package is installed globally. So here is the SOLUTION-------------

  1. Open PowerShell as an administrator. You can do this by right-clicking on the Windows Start button and selecting "Windows PowerShell (Admin)".

  2. In the PowerShell window, run the following command to check the current execution policy:

    powershell
    Get-ExecutionPolicy
  3. The output will be one of the following:

    • Restricted: This means that script execution is disabled. You need to change it to a more permissive policy.
    • AllSigned or RemoteSigned: These policies allow script execution but require digitally signed scripts. If you encounter this, you can skip changing the execution policy and try using the npx create-react-app command instead of create-react-app.
  4. To change the execution policy to allow script execution, run the following command:

    powershell
    Set-ExecutionPolicy Unrestricted
  5. You will be prompted to confirm the change. Type Y and press Enter.

  6. After changing the execution policy, you should be able to use the create-react-app command without encountering the "running scripts is disabled" error.

  7. Once you've finished using create-react-app, it's recommended to set the execution policy back to a more secure value. Run the following command:

    powershell
    Set-ExecutionPolicy Restricted

By following these steps, you should be able to resolve the script execution error and use create-react-app globally in any text editor.