Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

I'm getting error like this while creating react app

-->
create-react-app : File C:\Users\ADMIN\AppData\Roaming\npm\create-react-app.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
+ create-react-app demo
like image 665
Sagar Dhampalwar Avatar asked Jan 02 '20 10:01

Sagar Dhampalwar


People also ask

Why create React app doesn't work?

If you really need create-react-app , you might need to reinstall Node and reconfigure your dependencies to ensure you have a fresh start with Node, npm, npx, and the like. This is a good resource for updating and reinstalling Node.

How do you fix you are running create React app 4.0 3 which is behind the latest release 5.0 0 We no longer support global installation of create React app?

To solve the React. js error "You are running create-react-app 4.0. 3, which is behind the latest release (5.0. 0)", run the npx clear-npx-cache command and re-run your app creation command, e.g. npx create-react-app my-app .

Why NPX command is not working?

npx : The term 'npx' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.


7 Answers

I think you are using Windows, I came across the same problem and it's because of a security feature in your system.

  1. Open powershell as an administrator.
  2. Run the following command set-executionpolicy remotesigned
  3. Try again.

This worked for me.

Sources: https://www.faqforge.com/windows/windows-powershell-running-scripts-is-disabled-on-this-system/

like image 154
ShashankAC Avatar answered Sep 28 '22 09:09

ShashankAC


Make sure you remove create-react-app from npm globally and use npx create-react-app {project_name} to generate a react app.

npm uninstall --global create-react-app
npx create-react-app sample

also, make sure that your npm version is after 5.2 while doing these.

like image 39
Hamid Avatar answered Sep 28 '22 08:09

Hamid


Run power shell as admin

  1. Windows Start
  2. Search for "Windows Powershell"
  3. Right click Windows Powershell
  4. Click Run as Administrator (Grant in "User Account Control" if shows up)
  5. Type set-executionpolicy remotesigned
  6. Select/Type yes [Y]
like image 44
Marlon Avatar answered Sep 28 '22 09:09

Marlon


try this command : npx create-react-app yourappname

like image 32
DKR Avatar answered Sep 28 '22 08:09

DKR


This error comes because Microsoft changed some PowerShell execution policies for your security.

We can create react app from mainly two places.

  1. Command Prompt - You can easily create new react project without facing any issue.
  2. Powershell terminal in Visual code - If you not disables new policies of powershell yet then you will face such problem. You need follow some steps to disable these security features.
  • Run power shell as administrator
  • Type set-executionpolicy remotesigned
  • There will be 5 options.
  • You need to type Y (for [Y] Yes) and click Enter button.
  • Now you will be able to create react app in your visual code.

Hope it will work for you.

like image 22
Love Pandey Avatar answered Sep 28 '22 09:09

Love Pandey


  • run cmd as adminstrator then
  • cd to the folder you want to create the app in it and type the following

    create-react-app myapp

    this worked for me

like image 42
Youssef Kafa Avatar answered Sep 28 '22 09:09

Youssef Kafa


Simply run Power shell as administrator then execute the command:set-executionpolicy remotesigned

like image 35
Hussain Mahamud Avatar answered Sep 28 '22 09:09

Hussain Mahamud