Skip to content

Instantly share code, notes, and snippets.

@prabh-62
Created March 21, 2021 14:57
Show Gist options
  • Select an option

  • Save prabh-62/00bcd2b40fa3685682e03750619ae37e to your computer and use it in GitHub Desktop.

Select an option

Save prabh-62/00bcd2b40fa3685682e03750619ae37e to your computer and use it in GitHub Desktop.
Drawbacks of globally installing @angular/cli

Uninstall globally installed Angular CLI. Use npx

When we install @angular/cli globally, we pin the version of ng binary to a specific version which results in us using out-of-date ng binary most of the times(Angular CLI team publishes new version on a weekly basis). And if we are working in a team, we could be out of sync with the rest of developers since each dev might have different version of @angular/cli installed.

Check if you have @angular/cli installed globally

  • NPM npm list --global --depth 0
  • Yarn yarn global list

Uninstall global @angular/cli package

  • NPM npm uninstall --global @angular/cli
  • Yarn yarn global remove @angular/cli

How to create new angular workspace/projects?

  • New Angular Workspace npx @angular/cli new web-apps --create-application false
  • New application npx @angular/cli new admin-console npx tool comes bundled with Node.js, npx downloads latest verison of @angular/cli at that time and executes it on your machine.

How to generate angular components/services?

When @angular/cli generates a new project, it will also install @angular/cli locally in the newly created project. If you are using yarn package manager, you can simply run yarn ng generate component components/header inside the directory which has package.json and node_modules. If using NPM, one could directly invoke ng binary: node_modules/.bin/ng generate component components/header or npm run ng generate component components/header

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment