ng serve没问题,ng build发生错误

来源:4-7 路由概念

weixin_慕侠8488025

2019-10-22

在本地ng serve没问题,可以正常运行。
ng build --prod 确发生错误。
请帮我确认下错误原因。
谢谢!图片描述

写回答

3回答

weixin_慕侠8488025

提问者

2019-10-22

//img1.sycdn.imooc.com/szimg/5daf163e0991b98419201030.jpg1、let menu of menus

      menus 时数组(@Input() menus: TopMenu[] =[];)。menu时成员变量,这里时循环用的。menu并没有什么问题啊。

2、ng serve 能正常启动,无错误。

 

PS G:\A0050_soruce\050A0001_MyProject\002_angular8\selfLearning\pingduoduoTest> ng serve

10% building 3/3 modules 0 activei 「wds」: Project is running at http://localhost:4200/webpack-dev-server/

i 「wds」: webpack output is served from /   

i 「wds」: 404s will fallback to //index.html


chunk {main} main.js, main.js.map (main) 88.3 kB [initial] [rendered]

chunk {polyfills} polyfills.js, polyfills.js.map (polyfills) 264 kB [initial] [rendered]

chunk {runtime} runtime.js, runtime.js.map (runtime) 6.15 kB [entry] [rendered]

chunk {styles} styles.js, styles.js.map (styles) 9.93 kB [initial] [rendered]

chunk {vendor} vendor.js, vendor.js.map (vendor) 4.35 MB [initial] [rendered]

Date: 2019-10-22T14:51:42.815Z - Hash: 135f5533a32e02e16fae - Time: 12152ms

** Angular Live Development Server is listening on localhost:4200, open your browser on http://localhost:4200/ **

i 「wdm」: Compiled successfully.

 

3、ng build 能正常编译,无错误。

PS G:\A0050_soruce\050A0001_MyProject\002_angular8\selfLearning\pingduoduoTest> ng build


chunk {main} main-es2015.js, main-es2015.js.map (main) 86.9 kB [initial] [rendered]

chunk {polyfills} polyfills-es2015.js, polyfills-es2015.js.map (polyfills) 264 kB [initial] [rendered]

chunk {polyfills-es5} polyfills-es5-es2015.js, polyfills-es5-es2015.js.map (polyfills-es5) 617 kB [initial] [rendered]

chunk {runtime} runtime-es2015.js, runtime-es2015.js.map (runtime) 6.16 kB [entry] [rendered]

chunk {styles} styles-es2015.js, styles-es2015.js.map (styles) 9.93 kB [initial] [rendered]

chunk {vendor} vendor-es2015.js, vendor-es2015.js.map (vendor) 4.01 MB [initial] [rendered]

Date: 2019-10-22T14:54:37.570Z - Hash: d82d77ad7b8c4a8cc471 - Time: 9598ms

Generating ES5 bundles for differential loading...

ES5 bundle generation complete.

4、ng build --prod 时发生错误。

     要是变量有错误,前边(ng serve, ng build)就应该出错啊。

 还是有其他原因导致错误的呢?请确认,谢谢

1
2
weixin_慕侠8488025
按照你讲的方法,确实可以解决此问题。ng build --prod也不再报错。 我是按你的2-5视频 11:55(11分55秒左右开始) 的讲解视频做的,也许是你这里提一下就带带过了,讲漏了。(如果是这样大家都会有这个问题) 也许是你在后面哪里补讲了,我看漏了,没改程序。 后面我有时间再来确认此问题。 谢谢调查此问题。
2019-10-23
共2条回复

weixin_慕侠8488025

提问者

2019-10-23

 见下面

0
0

接灰的电子产品

2019-10-22

提示的错误信息已经很清楚了,menu 这个成员变量不存在,是不是拼写错了,应该是 menus 吧

0
0

Angular 开发拼多多webapp 从基础到项目实战

高仿拼多多WebApp,带你在实战环境中学习Angular

1322 学习 · 451 问题

查看课程