Uncaught Error: Cannot find module "tslib" when update to 3.9.2

I am facing with this issues, please advice. Thanks.

Uncaught Error: Cannot find module "tslib"
    at Object.<anonymous> (compiler.js:1)
    at __webpack_require__ (bootstrap a80b7ad41f732b859c1d:54)
    at Object.token.token (vendor.js:80606)
    at __webpack_require__ (bootstrap a80b7ad41f732b859c1d:54)
    at Object.251 (cache.ts:5)
    at __webpack_require__ (bootstrap a80b7ad41f732b859c1d:54)
    at webpackJsonpCallback (bootstrap a80b7ad41f732b859c1d:25)
    at main.js:100:


My package.json is:

"dependencies": {
    "@angular/common": "5.0.0",
    "@angular/compiler": "5.0.0",
    "@angular/compiler-cli": "5.0.0",
    "@angular/core": "5.0.0",
    "@angular/forms": "5.0.0",
    "@angular/http": "5.0.0",
    "@angular/platform-browser": "5.0.0",
    "@angular/platform-browser-dynamic": "5.0.0",
    "@ionic-native/admob-free": "^4.3.3",
    "@ionic-native/app-rate": "^4.3.3",
    "@ionic-native/background-mode": "^4.3.3",
    "@ionic-native/core": "4.3.3",
    "@ionic-native/deeplinks": "^4.3.3",
    "@ionic-native/device": "^4.3.3",
    "@ionic-native/in-app-browser": "^4.3.3",
    "@ionic-native/local-notifications": "^4.3.3",
    "@ionic-native/social-sharing": "^4.3.3",
    "@ionic-native/splash-screen": "4.3.3",
    "@ionic-native/status-bar": "4.3.3",
    "@ionic/pro": "1.0.11",
    "@ionic/storage": "2.1.3",
    "angular2-moment": "^1.7.0",
    "angularfire2": "^5.0.0-rc.3",
    "autoprefixer": "^7.1.6",
    "cordova-admob-sdk": "^0.11.1",
    "cordova-android": "~6.3.0",
    "cordova-plugin-admob-free": "^0.11.0",
    "cordova-plugin-app-event": "^1.2.1",
    "cordova-plugin-apprate": "^1.3.0",
    "cordova-plugin-background-mode": "^0.7.2",
    "cordova-plugin-device": "^1.1.4",
    "cordova-plugin-inappbrowser": "^1.7.1",
    "cordova-plugin-ionic-webview": "^1.1.16",
    "cordova-plugin-splashscreen": "^4.0.3",
    "cordova-plugin-whitelist": "^1.3.1",
    "cordova-plugin-x-socialsharing": "^5.2.1",
    "cordova-promise-polyfill": "0.0.2",
    "de.appplant.cordova.plugin.local-notification": "^0.8.5",
    "es6-promise-plugin": "^4.1.0",
    "firebase": "^4.6.1",
    "ionic-angular": "3.9.2",
    "ionic-plugin-deeplinks": "^1.0.15",
    "ionic-plugin-keyboard": "^2.2.1",
    "ionicons": "3.0.0",
    "promise-polyfill": "^6.0.2",
    "rxjs": "5.5.2",
    "sw-toolbox": "3.6.0",
    "zone.js": "0.8.18"
  "devDependencies": {
    "@ionic/app-scripts": "3.1.0",
    "typescript": "2.4.2"

I have the same problem… It seems to be a problem with angular’s build-optimizer which is enabled by default in the new angular-cli version… using ng build --prod --build-optimizer=false worked for me for other angular projects

So to fix it for ionic-app-scripts I had to copy the webpack config file from their repository https://github.com/ionic-team/ionic-app-scripts/blob/master/config/webpack.config.js , commented out the build-optimizer loaders and passed that to my npm script as a workaround, here’s what my npm script in my package.json looks like:

“build:prod”: “ionic-app-scripts --config (path-to-copied-webpack-file) build --prod”

ofc this is a workaround and the bundle size is not as small as it would be with the build-optimizer, but hey it works… hopefully the angular team can fix this soon

It is fixed. :slight_smile:

  1. I uninstalled angular/cli and install it again.
  2. update npm
  3. remove node_module folder
  4. npm install
    Now, It is working. :wink:
1 Like

I solved downgrading nodejs from v8.9.1 to v6.12.0

Use the command in CMD: npm i tslib

1 Like