npm uninstall -g angular-cli
npm cache clean
npm install -g @angular/cli@latest
ng new my-project
cd my-project
ng serve
** 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
添加到该组件的目录中。
ng serve