npm install express Error

npm install express error

I’ve just installed node.js and I wanted to install express.js framework as well. As a response I’ve received the error that you may see on the thumbnail image.

Luckily the resolution isn’t over too complicated. Here is a step by step guide:

Step 1: Open PowerShell as Administrator

  1. Search for PowerShell in the Windows Start Menu.
  2. Right-click on it and select Run as Administrator.

Step 2: Check the Current Execution Policy

Run the following command to check the current policy:

Get-ExecutionPolicy
  • You might see Restricted, which blocks all scripts.

Step 3: Change the Execution Policy

To allow running scripts temporarily, execute:

Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy RemoteSigned
  • Explanation:
    • -Scope CurrentUser: Limits the change to your user account.
    • -ExecutionPolicy RemoteSigned: Allows locally created scripts to run, but requires downloaded scripts to be signed by a trusted publisher.

Step 4: Confirm the Policy Change

When prompted, type Y and press Enter.


Step 5: Retry the Command

Go back to your project directory and run:

npm install express

Step 6: Revert the Policy (Optional)

If you’d like to revert to the original policy after installation, you can run:

Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy Restricted
Scroll to Top