1
votes

I was trying to build an angular project in a windows server.

I installed Angular CLI, node and npm but none of their commands are recognized as commands when I execute Windows batch command through Jenkins.

All the commands work fine when executed in cmd of the server.

I don't know how to explain this to google to get a perfect search result.So please help me guys ..

Thanks a lot !!!!

2

2 Answers

1
votes

Setting the PATH variable solved the issue for me.

In the build step I added this line before executing ng and npm commands.

set PATH=%PATH%;C:\Program Files\nodejs\;C:\Users\USER_NAME\AppData\Roaming\npm

Unfortunately all my attempts to set the PATH permanently failed.So I have to set the path evey time for a new build step in jenkins.

0
votes

Just to add to the above answer , this is what i am exactly doing in Jenkins for running a successful angular build without installing angular-cli in the server:

set PATH=%PATH%;C:\Users\Administrator\AppData\Roaming\npm;C:\Users\Administrator\AppData\Roaming\npm\node_modules\@angular\cli\bin;

@echo on
cmd /c npm install -g @angular/cli@latest

echo yarn Install
cmd /c yarn

echo Build    
ng build --prod --aot=true