Sagar Dhampalwar
Sagar Dhampalwar

Reputation: 341

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

Upvotes: 34

Views: 54601

Answers (10)

Love Pandey
Love Pandey

Reputation: 330

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.

Upvotes: 3

Veera velraj
Veera velraj

Reputation: 21

if you're a Windows OS user open your Powershell and paste the following command on your PowerShell cmd -> set-executionpolicy remotesigned.

Upvotes: 1

DKR
DKR

Reputation: 5744

try this command : npx create-react-app yourappname

Upvotes: 3

Hussain Mahamud
Hussain Mahamud

Reputation: 39

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

Upvotes: 3

Marlon
Marlon

Reputation: 1897

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]

Upvotes: 16

Ankit Aggarwal
Ankit Aggarwal

Reputation: 5

Don't worry, I also got this error. This error comes when you try to write the command create-react-app

when you type the command npm install -g create-react-app, after running this command you should restart the command prompt or command powershell whatever you are using. After restarting command prompt now you can type create-react-app cmd.

Upvotes: 0

Youssef Kafa
Youssef Kafa

Reputation: 21

  • 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

Upvotes: 2

ShashankAC
ShashankAC

Reputation: 1078

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/

Upvotes: 66

Thiru R
Thiru R

Reputation: 26

Just stop your node server in "task manager", and start. After that try to install with npx or npm.

Hope it is useful.

Upvotes: 0

Hamid
Hamid

Reputation: 727

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.

Upvotes: 22

Related Questions