我有一个项目已经开发了几个星期,并且在ionic serve
浏览器中运行良好。
然后我继续添加android平台,但是当我尝试构建它时,它失败并带有非常通用的消息。
我尝试使用开箱即用的构建(创建新项目ionic example start --v2
)然后ionic platform add android
,并在设备上构建和显示就好了。
输出结果不同:开箱即用......
ionic-app-scripts build
[17:02:31] ionic-app-scripts 0.0.47
[17:02:31] build dev started ...
[17:02:31] clean started ...
[17:02:31] clean finished in 7 ms
[17:02:31] copy started ...
[17:02:31] transpile started ...
[17:02:34] transpile finished in 2.66 s
[17:02:34] webpack started ...
[17:02:34] copy finished in 2.83 s
[17:02:41] webpack finished in 6.89 s
[17:02:41] sass started ...
[17:02:42] sass finished in 1.19 s
[17:02:42] build dev finished in 10.77 s
但这是我失败的......
[17:09:04] ionic-app-scripts 0.0.42
[17:09:04] build prod started ...
[17:09:04] clean started ...
[17:09:04] clean finished in 7 ms
[17:09:04] copy started ...
[17:09:04] ngc started ...
[17:09:05] copy finished in 227 ms
[17:09:11] can't resolve module apollo-client from C:/.../.tmp/app/app.module.ts
[17:09:11] Error: can't find symbol undefined exported from module C:/.../node_modules/apollo-client/index.d.ts, resolving symbol AppModule in C:/.../.tmp/app/app.module.ts, resolving symbol AppModule in C:/.../.tmp/app/app.module.ts
[17:09:11] ngc failed
[17:09:11] ionic-app-script task: "build"
[17:09:11] Error: Error
所以第一个区别是我的项目调用ngc
(角度编译器),它似乎与app.module.ts中列出的第一个模块有问题,在这种情况下是apollo-client。
我对角度和构建过程知之甚少,但是开箱即用的构建不会调用ngc
,这很奇怪。
无论采用哪种方式来构建和运行Android设备都可以做到?
编辑:
发现的另一个不同之处是,开箱即用的项目不会生成.tmp文件夹,我认为该文件夹是由ngc
本身创建的。
我还在开箱即用的项目中添加了apollo,它仍然有效(没有调用ngc。