在Angle 6工作区中安装NPM软件包 [英] Installing NPM packages in angular 6 workspace
问题描述
我刚刚使用Angular 6和CLI,并创建了一个如下所示的项目
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
在我的库中没有我想要添加 ngx-bootstrap
的组件,因为该组件将需要 DropdownButtonModule
,所以我的问题是如何为该组件安装npm软件包库?
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?
我以前只需要运行 npm install ngx-bootstrap
,但是现在将为应用程序安装软件包,但是,我需要为库安装该软件包.我应该进入库文件夹并运行npm install还是现在可以使用CLI完成此操作?
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?
推荐答案
您可以继续使用 npm install packagename
.
package.json不会附加到工作空间中的特定应用程序或库,而是附加到完整的angular/cli项目.构建过程(在后端使用webpack)将确定您各自活动的构建实际上需要哪些依赖项,然后删除其余的依赖项.
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.
这篇关于在Angle 6工作区中安装NPM软件包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!