Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't run 'ng' from VSTS agent

I'm trying to run unit tests against our AngularCLI project using our hosted VSTS build agents however it keeps running into trouble when it tries to run 'ng test'.

To resolve this I have tried to make the agent use the ng tool directly by providing the path to the tool. This hasn't worked as it looks like it's trying to run 'ng test' where the tool is rather than in the specified current working directory:

enter image description here

enter image description here

I've also tried to add it as an environment variable in Windows (we're using Windows Server 2012 to host the VSTS agent) and setting the tool in the VSTS agent as just ng however it doesn't appear to be finding the ng tool:

enter image description here enter image description here

How can I get the VSTS agent to make use of the ng tool to run tests? We have got @angular/cli installed on the server hosting the agent.

like image 595
Novastorm Avatar asked Sep 04 '17 09:09

Novastorm


1 Answers

The thing is that you won't get angular cli installed on VSTS globally as its build server is not supporting that. But the good thing you not even need cli globally installed on your agent.

All you need is npm run ng build -- prod - this way it will always run the local version. Also this way you won't need to take care of updating your global package at all.

Use npm run ng test to run tests, npm run ng e2e to run protractor. If you need to pass any more params to any of these just use --

like image 98
angularrocks.com Avatar answered Nov 13 '22 02:11

angularrocks.com