I'm getting an error message while trying to run serve -s build

Viewed 580

I was working on my first react project and now trying to deploy it in Netlify so I ran npm install -g serve then serve -s build after running npm run build but I'm getting the following error message while I ran serve -s build what is the problem here

serve : File C:\Users\Akhlak Hossain Jim\AppData\Roaming\npm\serve.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
+ serve -s build
+ ~~~~~
    + CategoryInfo          : SecurityError: (:) [], PSSecurityException
    + FullyQualifiedErrorId : UnauthorizedAccess
2 Answers

Now your PowerShell is preventing you from executing "possibly" harmful scripts, therefore, you have to change your execution policy, simply type this:
Set-ExecutionPolicy Unrestricted

May be you will need to start your terminal as an administrator in order to do this

I faced the same problem while trying to serve my react app using terminal of visual code. I just switched from the terminal of visual code to command prompt and it worked. But you have to install serve package in that folder(where your app currently resides) running command "npm install -g serve" first then run "serve -s build".

Related