DEV Community

Cover image for Best ways to fix Nodemon error- nodemon.ps1 cannot be loaded because running scripts is disabled on this system.
Osama Shaikh
Osama Shaikh

Posted on

3 2 2 2 2

Best ways to fix Nodemon error- nodemon.ps1 cannot be loaded because running scripts is disabled on this system.

Welcome to my blog, where we dive into the intriguing world of Node.js development and tackle one of the common stumbling blocks many developers encounter: the "Nodemon Error - nodemon.ps1 cannot be loaded because running scripts is disabled on this system." If you've ever come across this error while working with Nodemon, fear not! In this article, we will explore the causes behind this issue, understand why scripts are disabled on certain systems and most importantly, provide you with practical solutions to overcome this obstacle and keep your development workflow seamless. So, let's embark on this troubleshooting journey together and empower ourselves to conquer the Nodemon Error!

Error Image

Causes behind the Error⚠️

Before we dive into the solutions, let's first understand why the "nodemon.ps1 cannot be loaded" error occurs in the first place. By default, Windows PowerShell has a restricted execution policy, which means that it will only run scripts that are signed by a trusted publisher. This helps to prevent malicious scripts from being executed on your system.

2 ways to fix the error are🛠️:

  1. Unrestricting the Execution-Policy.
  2. Deleting the nodemon.ps1 from local device.

1. Unrestricting the Execution-Policy.

Step 1:

open Windows PowerShell as an administrator.

Step 2:

Run the following command in the PowerShell.



Get-ExecutionPolicy


Enter fullscreen mode Exit fullscreen mode

It will give you "Restricted" or "AllSigned" or "RemoteSigned". So, this is the main reason behind the error as running scripts on the system is 'Restricted'.

Step 3:

Use this command to make it Unrestricted -



Set-ExecutionPolicy Unrestricted


Enter fullscreen mode Exit fullscreen mode

After executing the command, you will get to see a prompt asking for allowance to change the execution policy.
Press Y to change the execution policy.
The problem is solved. Now you can use nodemon on your machine.

Disclaimer: Note that running scripts with an unrestricted execution policy can be a security risk. If you are not sure whether or not a script is safe to run, you should not run it.
This way is not much advisable as Changing the execution policy might expose you to the security risks described in the
about_Execution_Policies


2. Deleting the nodemon.ps1 from local device.

So we have another solution which is very easy and safe😍

Step 1:

Open your File Explorer and enter the path in the File path section



C:\Users\(Your username)\AppData\Roaming\npm


Enter fullscreen mode Exit fullscreen mode

File Location Image

Step 2:

Delete the file with name-->nodemon and type-->windows PowerShell script(.ps1) in properties.

File

File properties

Hooray! The error is fixed. Now you can use nodemon on your machine.

perfect output

This is the easiest and safest way as compared to the first way, Hence it is much advisable to use.
Now its upto you .... which one you choose.

Conclusion:

In conclusion, the "Nodemon Error - nodemon.ps1 cannot be loaded because running scripts is disabled on this system" can be a frustrating obstacle for Node.js developers. However, armed with the knowledge and solutions provided in this blog post, you are now prepared to overcome this issue and recover control of your Nodemon-powered development workflow.
In this article we have discussed 2 ways to fixed this error and both the ways are explained properly with pros and cons.
I hope this article has been helpful in troubleshooting and resolving this common issue.
Stay tuned🤗 for more insightful content, practical tips, and solutions to keep your development journey smooth and error-free. Happy coding😉!

Postmark Image

Speedy emails, satisfied customers

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up

Top comments (0)

nextjs tutorial video

📺 Youtube Tutorial Series

So you built a Next.js app, but you need a clear view of the entire operation flow to be able to identify performance bottlenecks before you launch. But how do you get started? Get the essentials on tracing for Next.js from @nikolovlazar in this video series 👀

Watch the Youtube series

👋 Kindness is contagious

Immerse yourself in a wealth of knowledge with this piece, supported by the inclusive DEV Community—every developer, no matter where they are in their journey, is invited to contribute to our collective wisdom.

A simple “thank you” goes a long way—express your gratitude below in the comments!

Gathering insights enriches our journey on DEV and fortifies our community ties. Did you find this article valuable? Taking a moment to thank the author can have a significant impact.

Okay