Angular实时开发服务器无法为新项目提供服务。
创始人
2024-10-29 12:00:40
0
  1. 首先,确保您的 Angular CLI 是最新版本。在终端中使用以下命令升级:
npm uninstall -g angular-cli
npm cache clean
npm install -g @angular/cli@latest
  1. 创建一个新的 Angular 项目:
ng new my-project
cd my-project
  1. 启动开发服务器:
ng serve
  1. 如果您看到以下错误:
** NG Live Development Server is listening on localhost:4200, open your browser on http://localhost:4200 **
Date: 2018-03-08T10:08:50.399Z
Hash: 5be9f283582e8993d9bf
Time: 6575ms
chunk {main} main.bundle.js, main.bundle.js.map (main) 16.2 kB {inline} [initial] [rendered]
chunk {polyfills} polyfills.bundle.js, polyfills.bundle.js.map (polyfills) 223 kB {inline} [initial] [rendered]
chunk {styles} styles.bundle.js, styles.bundle.js.map (styles) 10.4 kB {inline} [initial] [rendered]
chunk {vendor} vendor.bundle.js, vendor.bundle.js.map (vendor) 3.9 MB [initial] [rendered]
ERROR in multi ./src/styles.css
Module not found: Error: Can't resolve 'C:\src\styles.css' in 'C:\my-project\src'
 @ multi ./src/styles.css
webpack: Failed to compile.

这意味着开发服务器无法找到 styles.css。您可以手动创建此文件并添加样式,也可以使用 Angular CLI 自动创建:

ng generate component  --style=css

这将在 src/app 中创建一个新组件,并将 styles.css 添加到该组件的目录中。

  1. 现在重新启动开发服务器,您应该能够在浏览器中访问该项目了:
ng serve

相关内容

热门资讯

线上(wepoke真的)原来是... 线上(wepoke真的)原来是真的有挂!其实真的有挂(2022已更新)(哔哩哔哩);亲,其实确实真的...
两教程(Wepoke程序)软件... 两教程(Wepoke程序)软件透明挂辅助工具(软件透明挂)透视辅助(2024已更新)(哔哩哔哩);致...
软件(wepoke透明)原来是... 软件(wepoke透明)原来是真的有挂!其实真的有挂(2020已更新)(哔哩哔哩)是一款可以让一直输...
一模拟器(德扑工具)外挂辅助工... 一模拟器(德扑工具)外挂辅助工具(透视)透视辅助(2025已更新)(哔哩哔哩);亲真的是有正版授权,...
系统(aapoker讲解)竟然... 系统(aapoker讲解)竟然真的有挂!其实真的有挂(2021已更新)(哔哩哔哩);aapoker讲...
6系统(aapoker下载)外... 6系统(aapoker下载)外挂辅助工具(辅助挂)透视辅助(2023已更新)(哔哩哔哩)aapoke...
智能(德扑之星刷数据)果真真的... 智能(德扑之星刷数据)果真真的有挂!原来真的有挂(2025已更新)(哔哩哔哩);《WPK辅助透视》‌...
1机器人(德州nzt软件)软件... 1机器人(德州nzt软件)软件透明挂辅助软件(透视)透视辅助(2022已更新)(哔哩哔哩);人气非常...
ai代打(德扑之星决策)确实是... ai代打(德扑之星决策)确实是真的有挂!原来真的有挂(2020已更新)(哔哩哔哩);科技详细教程小薇...
第8透明(wepoke数据)外... 第8透明(wepoke数据)外挂透明挂辅助神器(辅助挂)透视辅助(2023已更新)(哔哩哔哩);原来...