Hi,
I’m trying to build the app while deploying but it doesn’t seem to find the commands angular-cli has ng build --env={environmentName}
as the first command in each deployment returns ng command not found.
I know it’s well over a month and I hope you found the answer. But for any future readers:
ng command isn’t being found because angular_cli isn’t installed. My work around for this, and I’m not sure it’s the best way to do it, is to add npm install angular-cli
to the npm start script.
EDIT
After learning how to better understand CircleCI I found that adding angular-cli as a dependency takes care of ng
commands, why didn’t I think of this later?
Example circle.yml
machine:
node:
version: 6.8.0
dependencies:
pre:
- npm install npm@latest -g # Should fix bug in ng test
- npm install angular-cli@latest -g
test:
override:
- npm run test
Using npm install angular-cli@latest -g
in dependencies -> pre
works, but there might be another way.
Since angular-cli is installed locally the npm scripts in package.json can access the ng
command (When evaluating scripts, npm adds node_modules/.bin/
to the PATH environment variable).
// This works with angular-cli installed locally only
{
"scripts": {
"test": "ng test --watch=false"
}
}
So if you can replace all you ng calls with npm scripts you dont have to install angular-cli globally.
I found it was a nice improvement because angular-cli would take ages (like 3 minutes++) to install globally and apparently would not be cached.
I tried the script you provided as well following script but I am still unable to run angular cli code in Circle.
dependencies:
override:
- nvm install 6 && npm install
test:
override:
- nvm use 6 && ng test
Angular CLI needs node 6 or above but in both the scripts, node 4 gets installed. I have SSHed the machines and verified it. Interestingly, if I manually run nvm use 6 && ng test
command (after SSH), my angular tests work.
Even though I have specified dependecies section, I notice that ‘npm install’ gets run instead of ‘nvm install 6 && npm install’