4

I installed Nodemon locally and globally, but in both cases I get the same error:

Nodemon : File C:\Users\xxx\AppData\Roaming\npm\nodemon.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
+ nodemon Books.js
+ ~~~~~~~
    + CategoryInfo          : SecurityError: (:) [], PSSecurityException
    + FullyQualifiedErrorId : UnauthorizedAccess. 

How to fix it?

Jeremy Caney
  • 7,102
  • 69
  • 48
  • 77
roman
  • 51
  • 1
  • 2
  • 4

6 Answers6

13

Hello please follow these you can solve this,
-> open Admin PowerShell
type these commands.
1)Set-ExecutionPolicy RemoteSigned
2)Set-ExecutionPolicy Unrestricted
3)Get-ExecutionPolicy
4)Exit

maybe your problem solve

Takbeer Ali
  • 129
  • 7
  • is it a secure solution? cuz the powershell itself gives me a warning – Mee Aug 01 '20 at 01:49
  • Only step 1 is necessary. More information [here](https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.security/set-executionpolicy?view=powershell-7.2). – Gabriel Candia Jan 13 '22 at 12:38
6

I have encountered this problem before and solved it like this:-

go to package.json, then attachment this to scripts:-

"start": "node app", "dev": "nodemon app"

it will be like this

"scripts": {
"start": "node app",
"dev": "nodemon app"},

then write in terminal npm run dev

note: app refer to the file name of your entry point

4

#You need to change the execution policy by doing these

  • open windows powershell(RUN AS ADMINISTRATOR)
  • Type - Get-ExecutionPolicy -> you will get 'Restricted' -Type - Set-ExecutionPolicy Unrestricted
  • type Y and hit enter
  • Now check if it changed to Unrestricted by typing Get-ExecutionPolicy -> you should get Unrestricted

go to VS code studio and in the terminal:

  • npm i nodemon -g(-g for globally installing it) -check installation by typing "nodemon -v" -> you will get the version installed now
  • Please check out the [formatting help page](https://stackoverflow.com/editing-help) to improve your formatting. – costaparas Feb 21 '21 at 01:10
1

In the package.json, replace scripts with this:

 "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "start": "node app",
    "dev": "nodemon app"   },

Now, open the terminal and type: npm run dev

Silla
  • 11
  • 1
1

On the terminal run this command:

Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
Tyler2P
  • 2,324
  • 26
  • 22
  • 31
Sangeetha
  • 11
  • 1
-1

can u try to create "bash terminal" 1 New terminal 2 Create bash teminal