Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
299 views
in Technique[技术] by (71.8m points)

How to install Angular CLI locally (without the -g flag)

I've just started working with Angular and with Angular-CLI and I've seen that, according to the documentation, I need to install $ npm install -g @angular/cli with the -g (global) flag.

However I would like to have Angular-CLI installed locally with the rest of my node_modules packages. This way, when I've download my project from git, I could simply run $ npm install (for installing all the dependencies in my package.json).

I try to create a new project by running $ npm init and then run $ npm i @angular/cli -D (-D is the same as --save-dev). But then when I run $ ng new project-name a new sub directory was created with a separate node_modules directory.

question from:https://stackoverflow.com/questions/48128847/how-to-install-angular-cli-locally-without-the-g-flag

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

As some of the comments suggest, you can have a local and global version of angular cli on your system.

To be able to access your local version instead of global (lets say you have a different version installed locally then your global install) use npm run-script ng

for example npm run-script ng generate component SomeCoolComponent

check out this answer on github to a similar question: https://github.com/angular/angular-cli/issues/5955#issuecomment-320273493


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...