Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about Collectives
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
I am seeing tutorials with NPM and Node.js that have the ng package handler. However, they run this straight from the command prompt. I am curious if I am missing something to install to run commands like
ng serve
for example, without having to preface them with
npm run
like
npm run ng serve --open
?
Thank you!
–
It's not recommended to install @angular/cli globally. Some projects will use different version of angular@cli and executing ng commands will have unexpected result.
Instead, install locally into dev dependencies with:
npm install --save-dev angular@cli
or Yarn:
yarn add --dev angular@cli
After you install locally, you can setup various npm scripts to execute ng
commands:
scripts: {
"dev": "ng serve"
Run the script:
npm run dev
** Please note, if you have globally installed angular@cli, running the commands mentioned above will use the local angular@cli package from node_modules/.bin.
Also, npx is a tool intended to help round out the experience of using packages from the npm registry. You can read about it more here
–
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.