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:
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
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:
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.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.
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 accountNT AUTHORITYNETWORK SERVICE
might not have the permissions to run the npm command.