Build in "prod" mode: Cannot find module "."

Hi everyone,

we have a large Ionic app that we’re trying to build in production mode since it’s almost ready. The first issue we found is that we were getting a “JavaScript heap out of memory” error when compiling, but we fixed it by giving more memory to node:

"ionic:build": "node --max-old-space-size=16384 ./node_modules/@ionic/app-scripts/bin/ionic-app-scripts.js build",

npm run ionic:build -- --prod

With this command the app successfully builds, but if I open it I get the following error:

Uncaught Error: Cannot find module “.”
at vendor.js:1
at vendor.js:1
at Object. (vendor.js:1)
at e (vendor.js:1)
at Object. (main.js:1)
at e (vendor.js:1)
at window.webpackJsonp (vendor.js:1)
at main.js:1

I searched a bit and I found that it could be caused by require, but we aren’t using it. Any idea of what could be going on or what we can do to debug the issue? Is there any way to use “–prod” without minifying the JS?

This is my environment:

cli packages: (/usr/local/lib/node_modules)

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

global packages:

cordova (Cordova CLI) : 6.5.0 
Gulp CLI              : [09:06:54] CLI version 3.9.1 [09:06:54] Local version 3.9.1

local packages:

@ionic/app-scripts : 3.1.9
Cordova Platforms  : android 6.1.2 ios 4.3.1
Ionic Framework    : ionic-angular 3.9.2


Android SDK Tools : 25.2.5
ios-deploy        : 1.9.1 
ios-sim           : 5.0.8 
Node              : v8.6.0
npm               : 5.3.0 
OS                : macOS High Sierra
Xcode             : Xcode 9.3.1 Build version 9E501 


backend : legacy

I also tried building like this:

npm run ionic:build -- --aot

But then I get an error saying it doesn’t find one of my providers (it is declared in app/app.module.ts).

Thank you!


I found the problem. In my package.json I was using:

"typescript": "^2.9.1",

Decreasing the version to ~2.6.2 fixed it for me. Now I’m getting another error, but I’ll open a new topic for that.


I downgraded to ^2.7.2, and the error was gone. :tada:


I have the same problem, but if I downgrade to less than typescript 3 I screw up my angular 7 dependency. Isn’t thare any patch for this problem? I read something about this having to do with angular’s ahead of time compiler…

Trying to use Angular 7 with Ionic 3 is also unsupported, so you may want to look into moving to the Ionic 4 beta.


Downgrading to typescript version 2.7.2 fixed the issue for me as well

What’s the problem? You mean there is a critical change between typescript 2.7 and 2.8?
Update: Since rxjs 6, it requires Typescript 2.8 or later. See

In my case, with typescript 2.7 and rxjs 6 I can’t build. But if I update to typescript 2.9 the production build brings the module “.” error on runtime. Finally typescript 2.8 seems to works.


Does anyone have a solution to this? Like mentioned before, downgrading is a workaround that doesn’t work for everyone. I use Angular 7, rxjs and I can’t downgrade to typescript < 3.1.1. I am also on Ionic 4 as suggested. Here’s my Ionic Info:


ionic (Ionic CLI) : 4.10.2
Ionic Framework : ionic-angular 3.9.5
@ionic/app-scripts : 3.2.3


cordova (Cordova CLI) : 8.1.2 (cordova-lib@8.1.1)
Cordova Platforms : android 7.0.0, ios 4.5.4
Cordova Plugins : cordova-plugin-ionic-keyboard 2.0.5, cordova-plugin-ionic-webview 4.0.1, (and 17 other plugins)


ios-deploy : 1.9.2
ios-sim : 5.0.13
NodeJS : v6.10.2 (/usr/local/bin/node)
npm : 3.10.10
OS : macOS Mojave
Xcode : Xcode 10.2 Build version 10E125

it worked for me by installing the typescript to 2.8

1 Like

Hola @afelipelli pudiste encontrar la solución?

Nope. I could not. I had to rollback all the upgrades I had made (including Angular and rxjs) and change some code that didn’t work in these old versions. Very frustrating but that was the only way to move forward, unfortunately.

This works for me, Thanks @MGA93 .

“Downgrading to typescript version 2.7.2 fixed the issue for me as well”

In a production build, I had the same problem using TypeScript 3.5.x. I tried the suggested downgrade to TypeScript 2.8.x and I was able to load a production build successfully. I had a few places where I was using newer TypeScript features that I needed to code differently, but it loads now.

Well, I have the same error, but setting the typescript version to 2.7.2 or 2.6.2 didn’t help.

To give more background… The app used to work with what was probably typescript 2.6.2, then I needed to use some component that didn’t work for me, so I basically updated everything including ionic and it broke my build (ionic serve still works of course). Now I tried to reconstruct the previous state from the package-lock and package from when it worked. I did so and it didn’t help. Now I tried messing with the typescript version, but it also doesn’t help.

Now I think that the only thing that is different is the ionic version. At this point I am running 3.9.2 as does the OP. I would go back but I have no idea which version I was using before. I do not remember… I had it installed globally, so I have no package.json history for that.

Any ideas on how to either solve the problem or find out the ionic version that I was using before? Some logs maybe…


//edit: I have also tried updating app-scripts and cordova, but still getting the same error…

Any ideas what other stuff can I try to get it working? At this point, whatever I do, I just get white screen… And the error in console described by the OP.

I have tried building the old versions from the repo history and I have the same problem. White screen and this console output:

Viewport argument key "viewport-fit" not recognized and ignored. [index.html:9](file:///android_asset/www/index.html)

Uncaught Error: Cannot find module "." [vendor.js:1](file:///android_asset/www/build/vendor.js)

Ionic Native: deviceready event fired after 868 ms [vendor.js:1](file:///android_asset/www/build/vendor.js)

It has to be ionic version somehow. Any ideas, what I could try?

@yagodorea did you find any solution?

1 Like

same issue here, did any find a solution?

@nextbyn Yeah I Had to downgrade my typescript,angular,and mobx versions to resolve this issue

I can’t downgrade typescript;

Error: The Angular Compiler requires TypeScript >=3.4.0 and <3.6.0 but 2.8.3 was found instead.

Any solution?