遇到ERESOLVE错误时,可以尝试运行以下命令:
npm cache clean --force npm install
如果上述命令无效,则可以尝试升级npm和node版本,或者采用指定版本的安装方式。具体可以参考以下示例:
npm install bootstrap@4.1.1 npm install jquery@3.5.1 npm install popper.js@1.14.3
其中,版本号可以根据自己的需求进行指定。安装完成后,在angular.json文件中添加以下代码:
"styles": [ "node_modules/bootstrap/dist/css/bootstrap.min.css", "src/styles.css" ], "scripts": [ "node_modules/jquery/dist/jquery.min.js", "node_modules/popper.js/dist/umd/popper.min.js", "node_modules/bootstrap/dist/js/bootstrap.min.js" ]
此时,bootstrap就已经成功添加到Angular项目中了。