简体   繁体   English

在角度6工作空间中安装NPM包

[英]Installing NPM packages in angular 6 workspace

I am just picking up Angular 6 and CLI and have created a project as below 我只是选择了Angular 6和CLI并创建了一个项目,如下所示

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? 在我的库中没有我想添加ngx-bootstrap因为组件需要DropdownButtonModule所以我的问题是如何为库安装npm包?

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. 我以前刚刚运行npm install ngx-bootstrap但现在将为应用程序安装软件包,但是,我需要为库安装此软件包。 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? 我应该cd到库文件夹并运行npm install还是有另一种方法,这是使用CLI完成的?

You can continue to use npm install packagename . 您可以继续使用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. package.json未附加到工作区中的特定应用程序或库,而是附加到完整的angular / cli项目。 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. 构建过程(在后端使用webpack)将确定哪些依赖项对于您的相应活动构建实际上是必需的,并删除其余的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM