Installing NPM packages in angular 6 workspace

孤者浪人 提交于 2021-02-07 12:56:24

问题


I am just picking up Angular 6 and CLI and have created a project as below

ng new my-demo
cd my-demo
ng g library foo --prefix=my

No in my library I want to add ngx-bootstrap as the component will need the DropdownButtonModule so my question is how do I go about installing the npm package for the library?

I would previously have just run npm install ngx-bootstrap but this will now install the package for the application, however, I need this installed for the library. Should I be cd'ing to the library folder and running npm install or is there an alternate way this is n ow done using the CLI?


回答1:


You can continue to use npm install packagename.

The package.json is not attached to a specific application or library within your workspace, but to your complete angular/cli project. The build process (using webpack in the backend) will figure out which dependencies are actually necessary for your respective active build and drop the rest.



来源:https://stackoverflow.com/questions/50232682/installing-npm-packages-in-angular-6-workspace

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!