Ionic 3: Build in “prod” mode: Cannot find module “.”

PX Developer

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
System:

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 
Misc:

backend : legacy

Thank you!

PX Developer

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.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Ionic Cordova Build prod: Cannot find module “.” - Typescript version >3

From Dev

Cannot build IONIC iOS --prod showing error

From Dev

Why is Ionic 3 apk build with '--prod --release android' giving Google playstore error that apk was signed in debug mode?

From Dev

Cannot determine the module for class - ng build --prod

From Dev

ionic cordova build android Cannot find module '../pages/Wallet/'

From Dev

Ionic build error Cannot find module './scheduler/Action'

From Dev

"Error: Cannot find module '@app/foo'" in prod mode when using libs

From Dev

Ionic 3 Prod Build With Version Number

From Dev

Cannot find module “.” when building prod release

From Dev

Ionic3 - Uncaught Error: Cannot find module '.'

From Dev

Ionic 3 Angular 4 Cannot find module `jsonwebtoken`

From Dev

IONIC build PROD

From Dev

ng build cannot find module

From Dev

Ionic 3 build --prod causes white screen on iOS only

From

Ionic 3 prod release build issue with intellij-core-26.0.1

From Dev

Ionic 3 - App shows blank screen after build with --prod

From Dev

Ionic build cannot find module error. How to import Android plugin?

From Dev

Dynamic Environment Variables in Ionic - Cannot find module

From Dev

Cannot find module generated with “Ionic g provider”

From Dev

Ionic 2 - Runtime error Cannot find module "."

From Dev

Ionic 2 cannot find module 'dgram'

From Dev

Cannot find module "ionic-native"

From Dev

Ionic => Runtime error: Cannot find module "."

From Dev

Ionic/Angular Issue Cannot find module './fs'

From Dev

Cannot find Ionic-angular module

From Dev

NestJS: Cannot find module in dev mode

From Dev

Cannot find name 'cordova'. ionic build ios

From Dev

Cannot find module "d3" error is displayed after i upgraded my project from ionic 2 to ionic 3

From Dev

Runtime Error: Cannot find module "leaflet.awesome-markers" Ionic 3

Related Related

  1. 1

    Ionic Cordova Build prod: Cannot find module “.” - Typescript version >3

  2. 2

    Cannot build IONIC iOS --prod showing error

  3. 3

    Why is Ionic 3 apk build with '--prod --release android' giving Google playstore error that apk was signed in debug mode?

  4. 4

    Cannot determine the module for class - ng build --prod

  5. 5

    ionic cordova build android Cannot find module '../pages/Wallet/'

  6. 6

    Ionic build error Cannot find module './scheduler/Action'

  7. 7

    "Error: Cannot find module '@app/foo'" in prod mode when using libs

  8. 8

    Ionic 3 Prod Build With Version Number

  9. 9

    Cannot find module “.” when building prod release

  10. 10

    Ionic3 - Uncaught Error: Cannot find module '.'

  11. 11

    Ionic 3 Angular 4 Cannot find module `jsonwebtoken`

  12. 12

    IONIC build PROD

  13. 13

    ng build cannot find module

  14. 14

    Ionic 3 build --prod causes white screen on iOS only

  15. 15

    Ionic 3 prod release build issue with intellij-core-26.0.1

  16. 16

    Ionic 3 - App shows blank screen after build with --prod

  17. 17

    Ionic build cannot find module error. How to import Android plugin?

  18. 18

    Dynamic Environment Variables in Ionic - Cannot find module

  19. 19

    Cannot find module generated with “Ionic g provider”

  20. 20

    Ionic 2 - Runtime error Cannot find module "."

  21. 21

    Ionic 2 cannot find module 'dgram'

  22. 22

    Cannot find module "ionic-native"

  23. 23

    Ionic => Runtime error: Cannot find module "."

  24. 24

    Ionic/Angular Issue Cannot find module './fs'

  25. 25

    Cannot find Ionic-angular module

  26. 26

    NestJS: Cannot find module in dev mode

  27. 27

    Cannot find name 'cordova'. ionic build ios

  28. 28

    Cannot find module "d3" error is displayed after i upgraded my project from ionic 2 to ionic 3

  29. 29

    Runtime Error: Cannot find module "leaflet.awesome-markers" Ionic 3

HotTag

Archive