-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathangular-cli.txt
More file actions
120 lines (30 loc) · 1.63 KB
/
angular-cli.txt
File metadata and controls
120 lines (30 loc) · 1.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
【1】package.json的项目启动配置:
"scripts": {
"ng": "ng",
"start": "ng serve --host 0.0.0.0 --port 6060 --proxy-config proxy.conf.json",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
@angular/cli 6.0.8
(1)创建ng项目:
npm install @angular/cli -g
ng new 项目名 --routing --style scss //自动生成带有路由配置的项目并且使用scss写样式
ng set --global packageManager=cnpm (设置后以后再用ng new创建项目时会自动用cnpm来安装包,仅需设置一次, 但还是不要指定cnpm吧,有时会出问题)
cd 项目名
npm install
ng serve --open
(2)如果在执行ng serve时报错: Cannot find module 'webpack/lib/node/NodeTemplatePlugin’
解决办法:在项目中安装webpack, 及npm install wepack --save-dev
(3)当ng项目目录被移动时,一般再启动ng serve时会报错,此时可以删除node-modules文件夹,执行cnpm install命令,重新下载所有npm包
(4)ng [命令名 子命令名 ...] --help ------ 查看相关命令的配置参数 例:ng generate --help 或 ng generate module --help
(5)创建一个路由模块: ng generate module 模块名(前面可以有路径) --routing
(6)创建一个自定义前缀的内联样式和模板的组件(并确认属于哪个模块):ng generate component 组件名(前面可以有路径) --inline-style --inline-template --prefix base --module base
简写:ng g component 组件名(前面可以有路径) -s -t -p base -m base
@angular/cli 6.1.5
(1)ng new hsForecastSystem --routing --style scss
@angular/cli 7.0.6 (node10.13.0, yarn1.12.3)
(1)ng help 查看所有命令说明
(2)ng commandName --help 查看子命令说明
(3)我一般用这个命令构建一个项目:ng new appName --routing --style scss