skip to Main Content

I am getting below error at ‘npm custom’ custom in Azure Pipeline, while triggering it.

##[error]Error: Unable to locate executable file: ‘npm’. Please verify either the file path exists or the file can be found within a directory specified by the PATH environment variable. Also verify the file has a valid extension for an executable file.

PFA snapshot for reference:

Pipeline logs

Please guide here.

I tried adding Node Tool Installer before npm custom step, but then Node Tool Installer failed with:

##[error]read ECONNRESET

Then I also added Use Node 16.x step, this also failed with :

##[error]read ECONNRESET

I have already added the npm path in Environment variable PATH, but this also isn’t helping as still I am getting the below error:

##[error]Error: Unable to locate executable file: ‘npm’. Please verify either the file path exists or the file can be found within a directory specified by the PATH environment variable. Also verify the file has a valid extension for an executable file.

2

Answers


  1. You may reboot your machine containing build agents to reread environment variables if you installed npm manually. Additionally, you may add your custom agent capabilities to your build agent:

    enter image description here

    Login or Signup to reply.
  2. As you are using a self-hosted agent, you can log in directly to this machine and run the npm command to see if the same error is reported.
    For example, run the npm version command in your agent manaully, and check the result.

    enter image description here

    If the same error is reported, there is a problem with the node.js installation itself on your machine. You can download the Node.js and reinstall it manually.

    After the reinstallation, restart the self hosted agent. Then you can check the agent capabilities to see if the nodejs and npm is listed.

    enter image description here

    If there is no problem running the npm command directly on the agent and the nodejs and npm is listed in the agent capabilities, please try to reconfigure a self-hosted agent. When configuring, set the agent service login to the local account. Do not use the default Windows built-in account NT AUTHORITYNETWORK SERVICE. The account NT AUTHORITYNETWORK SERVICE might not have the permissions to run the npm command.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search