ionic-team / ionic-app-scripts

App Build Scripts for Ionic Projects
http://ionicframework.com/
MIT License
608 stars 302 forks source link

Typescript error when building production only #1466

Open jmmobley opened 6 years ago

jmmobley commented 6 years ago

Hi,

When executing ionic build --prod I get the following error:

Error: The Angular Compiler requires TypeScript >=2.7.2 and <2.8.0 but 2.9.2 was found instead. at checkVersion (C:\Development\CareHere\Portal\src\Client.Device\ClientApp\node_modules\@angular\compiler-cli\src\transformers\program.js:806:19) at new AngularCompilerProgram (C:\Development\CareHere\Portal\src\Client.Device\ClientApp\node_modules\@angular\compiler-cli\src\transformers\program.js:109:13) at Object.createProgram (C:\Development\CareHere\Portal\src\Client.Device\ClientApp\node_modules\@angular\compiler-cli\src\transformers\program.js:812:16) at Object.createProgram (C:\Development\CareHere\Portal\src\Client.Device\ClientApp\node_modules\@angular\compiler-cli\src\ngtools_api2.js:36:26) at C:\Development\CareHere\Portal\src\Client.Device\ClientApp\node_modules\@ionic\app-scripts\dist\aot\aot-compiler.js:210:40 at step (C:\Development\CareHere\Portal\src\Client.Device\ClientApp\node_modules\@ionic\app-scripts\dist\aot\aot-compiler.js:32:23) at Object.next (C:\Development\CareHere\Portal\src\Client.Device\ClientApp\node_modules\@ionic\app-scripts\dist\aot\aot-compiler.js:13:53) at fulfilled (C:\Development\CareHere\Portal\src\Client.Device\ClientApp\node_modules\@ionic\app-scripts\dist\aot\aot-compiler.js:4:58) at

Here is my environment info:

@ionic/cli-utils  : 1.19.2
ionic (Ionic CLI) : 3.20.0

global packages:

cordova (Cordova CLI) : 8.0.0

local packages:

@ionic/app-scripts : 3.1.10
Cordova Platforms  : android 7.0.0 ios 4.5.4
Ionic Framework    : ionic-angular 3.9.2

System:

Node : v8.11.1
npm  : 6.4.0
OS   : Windows 10

Environment Variables:

ANDROID_HOME : not set

Misc:

backend : pro

I am using Angular 6, and Typescript 2.9.2 as stated in the error. How can

This compiles just fine in dev mode and my app works perfectly, but fails anytime --prod is specified, including cordova builds.

How can I disable this check? Clearly it isn't necessary or dev shouldn't work.

Stiwoz commented 5 years ago

Not sure if this will help you, but I noticed that if I have Typescript 3.x.x installed globally and I install Typescript 2.8.x locally (npm i -S Typescript@2.8.0) the compiler uses the local version instead of the global one. If you use vs-code you should see in the bottom right the Typescript version in use. Clicking on it opens a popup where you can choose which version to use. See the attached screenshots.

screenshot 2018-10-12 at 11 24 41 screenshot 2018-10-12 at 11 24 50