angular2-cli 给出@multi 样式错误

新手上路,请多包涵

我最近开始使用 angular2-cli 并创建了一个新项目。我想在我的项目中使用引导程序,因此我安装了引导程序,然后想要导入引导程序 css 文件,就像它在此处的 angular2-cli 指南中显示的那样。 https://github.com/angular/angular-cli#global-library-installation 运行 ng serve 后出现以下错误。

找不到多样式中的错误模块:错误:无法解析“/home/krishna/angular2_migrate/webui/node_modules”中的“/home/krishna/angular2_migrate/webui/node_modules/bootstrap/dist/css/bootstrap.min.css” /angular-cli/models’ @多样式

我究竟做错了什么 ?

angular2-cli 版本信息

krishna@Krishna:~/angular2_migrate/webui$ ng version
Could not start watchman; falling back to NodeWatcher for file system events.
Visit http://ember-cli.com/user-guide/#watchman for more info.
angular-cli: 1.0.0-beta.17
node: 4.4.3
os: linux x64

原文由 codestruggle 发布,翻译遵循 CC BY-SA 4.0 许可协议

阅读 365
2 个回答

在路径前添加 ../。

在 angular-cli.json 中,

 "styles": [
  "../node_modules/bootstrap/dist/css/bootstrap.min.css",
  "styles.scss"
]

更新

在 angular7 中,有 angular.json 文件,您不需要在路径前添加 ../

原文由 Noopur Dabhi 发布,翻译遵循 CC BY-SA 4.0 许可协议

为 node_modules 提供完整的物理路径。我已经为 css 文件提供了完整的物理路径并最终解决了问题

原文由 Karthic Mohandhoss 发布,翻译遵循 CC BY-SA 4.0 许可协议

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题