OPV*_*OPV 2 dependencies angular angular7
我已经使用 CLI 安装了最新版本的 Angular。根目录中有package.json。我运行命令:npm install。它安装了依赖项。
当我尝试在应用程序中使用包时,pipe或者component类似:
import * as _ from 'lodash';
Run Code Online (Sandbox Code Playgroud)
它找不到这个依赖项。如何在新的 Angular 中使用和安装 npm 包?
安装依赖项的正确方法是使用package json。
因此需要将包添加到该文件的"dependencies": {}section中。
npm install然后在放置该文件的根目录中运行。在 Angular 了解所有依赖关系之后,您可以将它们导入到组件、管道等中。