# Ng: command not found (angular-cli & yarn)

**URL:** <https://discuss.circleci.com/t/ng-command-not-found-angular-cli-yarn/8073>\
**Category:** Build Environment\
**Tags:** angular, npm, yarn\
**Created:** [November 13, 2016, 6:41pm UTC](https://discuss.circleci.com/t/ng-command-not-found-angular-cli-yarn/8073 "2016-11-13T18:41:47Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jeffarese](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/jeffarese/32/14390_2.png) [@Jeffarese](https://discuss.circleci.com/u/Jeffarese)\
**Post date:** [November 13, 2016, 6:41pm UTC](https://discuss.circleci.com/t/ng-command-not-found-angular-cli-yarn/8073/1 "2016-11-13T18:41:48Z")

</div>

I’m trying to test the speed improvements of Yarn vs npm.

In this project, with npm I was using the following file:

```auto
machine:
  node:
    version: 6.5.0
test: 
  override: 
  - ng test --watch=false

```

Now, following the docs, trying to use Yarn, I’m using this config in circle.yml

```auto
machine:
  pre:
    - mkdir ~/.yarn-cache
  node:
    version: 6.5.0
dependencies:
  pre:
    - sudo apt-key adv --fetch-keys http://dl.yarnpkg.com/debian/pubkey.gpg
    - echo "deb http://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
    - sudo apt-get update -qq
    - sudo apt-get install -y -qq yarn
  cache_directories:
    - ~/.yarn-cache
  override:
    - yarn
test:
  override:
    - ng test --watch=false

```

But in the **ng-test** I get the following error:

```auto
bash: line 1: ng: command not found

ng test --watch=false returned exit code 127

```

**angular-cli** is listed as a devDependency in the **package.json** , so the yarn command itself should install it, just as the npm install did with npm, right?

---

<div class="post-metadata">

**Author:** ![levlaz](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/levlaz/32/36978_2.png) [@levlaz](https://discuss.circleci.com/u/levlaz)\
**Post date:** [November 14, 2016, 4:45am UTC](https://discuss.circleci.com/t/ng-command-not-found-angular-cli-yarn/8073/2 "2016-11-14T04:45:01Z")

</div>

I don’t think this has to do with yarn. I am a bit confused on how this ever worked.

`ng test` assumes that `ng` is installed globally. Otherwise you would need to to execute the absolute command `node_modules/angular-cli/bin/ng` _unless_ you are calling it as a part of a script from `package.json`.

Could you share your circle.yml from when you were doing this without yarn?

Ultimately there are two options (as far as I know)

1. Install angular-cli globally `npm install -g angular-cli` so that you can call `ng` from any context
2. Make a script in `package.json` such as:

```auto
{
  "scripts": {
    "test": "ng test --watch=false"
  }

```

and then execute it with

```auto
test:
  override:
    - npm run test

```

## Update

I ran a [build](https://circleci.com/gh/levlaz/circleci-testing/99) using just npm and it totally works just like you said.

## Update 2

I see whats is going on here. The reason why “plain” npm just works is because our inference engine is exporting node\_modules as a part of the build dependency step. When you run `override` it no longer runs this step so then the `node_modules` dependencies are no longer in the PATH.

> [@Jeffarese](#):
>
> override:  
> - yarn

So the way to get this to work would be:

1. Add `node_modules/.bin` to the PATH
2. Make a script in package.json
3. Install angular-cli globally

---

<div class="post-metadata">

**Author:** ![Jeffarese](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/jeffarese/32/14390_2.png) [@Jeffarese](https://discuss.circleci.com/u/Jeffarese)\
**Post date:** [November 14, 2016, 8:36pm UTC](https://discuss.circleci.com/t/ng-command-not-found-angular-cli-yarn/8073/3 "2016-11-14T20:36:29Z")

</div>

Oh, you are right! I think the first approach ( making a script in package.json) would be a better approach, because if I have to install globally angular-cli with every build I’ll lose like 30-60 seconds.

Do you know if pre-installing Yarn in machines is on the roadmap of CircleCi?

Thanks for your help!

---

<div class="post-metadata">

**Author:** ![levlaz](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/levlaz/32/36978_2.png) [@levlaz](https://discuss.circleci.com/u/levlaz)\
**Post date:** [November 14, 2016, 11:41pm UTC](https://discuss.circleci.com/t/ng-command-not-found-angular-cli-yarn/8073/4 "2016-11-14T23:41:40Z")

</div>

My pleasure!

> [@Jeffarese](#):
>
> Do you know if pre-installing Yarn in machines is on the roadmap of CircleCi?

Yes for sure, I am working with the build image team to get this done in the [next image update](https://discuss.circleci.com/t/preinstall-yarn/7353).

Please keep in mind though that having it pre-installed will not address this specific issue. We would need to update our inference engine to handle yarn in order to make this completely automated.

---

<div class="post-metadata">

**Author:** ![Jeffarese](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/jeffarese/32/14390_2.png) [@Jeffarese](https://discuss.circleci.com/u/Jeffarese)\
**Post date:** [November 16, 2016, 11:21am UTC](https://discuss.circleci.com/t/ng-command-not-found-angular-cli-yarn/8073/5 "2016-11-16T11:21:21Z")

</div>

Perfect 🙂  
Thank your for your help 😃

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/circleci/original/3X/5/1/511608acda8e85906e15909b57bd0a46c1dbe291.png) [@system](https://discuss.circleci.com/u/system)\
**Post date:** [June 18, 2018, 11:38am UTC](https://discuss.circleci.com/t/ng-command-not-found-angular-cli-yarn/8073/6 "2018-06-18T11:38:53Z")

</div>

Closed on June 18, 2018, 11:38am UTC


