Uncaught Error: Cannot resolve all parameters for 'PlatformRef_'(?)

I’m trying to release a production browser build, but running into a problem, which doesn’t seem to be stemming from my own code.

ionic serve works fine, not runtime problems.

ionic cordova build browser --prod completes the production browser build successfully, without any errors or warnings:

ionic cordova build browser --prod
  Running app-scripts build: --prod --iscordovaserve --externalIpRequired --nobrowser
[13:51:54]  build prod started ...
[13:51:54]  clean started ...
[13:51:54]  clean finished in 6 ms
[13:51:54]  copy started ...
[13:51:54]  ngc started ...
[13:52:02]  ngc finished in 7.70 s
[13:52:02]  preprocess started ...
[13:52:02]  deeplinks started ...
[13:52:02]  deeplinks finished in 270 ms
[13:52:02]  optimization started ...
[13:52:02]  copy finished in 8.15 s
[13:52:17]  optimization finished in 15.37 s
[13:52:17]  preprocess finished in 15.64 s
[13:52:17]  webpack started ...
[13:53:36]  webpack finished in 78.19 s
[13:53:36]  sass started ...
[13:53:36]  uglifyjs started ...
[13:53:37]  sass finished in 1.23 s
[13:53:37]  cleancss started ...
[13:53:39]  cleancss finished in 1.89 s
[13:53:56]  uglifyjs finished in 20.06 s
[13:53:56]  postprocess started ...
[13:53:56]  postprocess finished in 48 ms
[13:53:56]  lint started ...
[13:53:56]  build prod finished in 121.67 s
✔ Running build - done!
/ Executing cordova command: cordova build browser [13:54:04]  lint finished in 8.28 s
✔ Executing cordova command: cordova build browser - done!

However, when I deploy the www directory to a web server and run the app, I get:

Uncaught Error: Cannot resolve all parameters for 'PlatformRef_'(?). Make sure that all the parameters are decorated with Inject or have valid type annotations and that 'PlatformRef_' is decorated with Injectable.
    at g (http://localhost/www/build/polyfills.js:3:7133)
    at noAnnotationError (http://localhost/www/build/main.js:1:10428)
    at _dependenciesFor (http://localhost/www/build/main.js:1:14098)
    at resolveReflectiveFactory (http://localhost/www/build/main.js:1:11711)
    at resolveReflectiveProvider (http://localhost/www/build/main.js:1:12285)
    at Array.map (native)
    at resolveReflectiveProviders (http://localhost/www/build/main.js:1:12457)
    at Function.ReflectiveInjector.resolve (http://localhost/www/build/main.js:4:24489)
    at Function.ReflectiveInjector.resolveAndCreate (http://localhost/www/build/main.js:4:24642)
    at http://localhost/www/build/main.js:1:17446
    at http://localhost/www/build/main.js:1:17319
    at Object.<anonymous> (http://localhost/www/build/main.js:89:23420)
    at __webpack_require__ (http://localhost/www/build/main.js:1:223)
    at http://localhost/www/build/main.js:1:988
    at http://localhost/www/build/main.js:1:1035

I’ve disabled uglifyjs temporary to reveal that the erorr is around PlatformRef_ and understand that it’s either a circular dependency or incorrect injection flow, but I can’t determine where the problem actually comes from.
Most likely it’s a third-party package incompatibility, but there’s no info to pinpoint which one.

I’ve recently upgraded my ionic cli to v3 beta. When I tried to replicate the issue following your steps. I copied www folder to another location in my laptop and fired index.html. I didn’t see any issues other than CORS issue that I need to resolve. Refer to attached snapshots and check if you have all contents of www copied to your web server.


I’ve also tried to host this in gh-pages and works fine. Here is the URL if you want to test it yourself. www folder

If you can share your environment details by running Ionic info, I can check further.

Your app.module.ts would probably be helpful.

Thank you for your quick replies!
I’ve taken a different approach to pinpoint the problem and, unfortunately, was able to reproduce it with a blank Ionic project.

If I do ionic start test blank --v2 and then ionic cordova build browser --prod, everything is fine with whatever package versions come with ionic cli v3 beta.

I then updated all packages to their latest version and got the error again:
Uncaught Error: Cannot resolve all parameters for 'e'(?). Make sure that all the parameters are decorated with Inject or have valid type annotations and that 'e' is decorated with Injectable.

I’m currently removing non-essentials packages to narrow down the one whose newer version causes the problem.
So far this package.json doesn’t break the production build for the blank ionic project:

  "name": "ionic-test",
  "author": "Ionic Framework",
  "homepage": "http://ionicframework.com/",
  "private": true,
  "scripts": {
    "clean": "ionic-app-scripts clean",
    "build": "ionic-app-scripts build",
    "ionic:build": "ionic-app-scripts build",
    "ionic:serve": "ionic-app-scripts serve"
  "dependencies": {
    "@angular/common": "4.0.0",
    "@angular/compiler": "4.0.0",
    "@angular/compiler-cli": "4.0.0",
    "@angular/core": "4.0.0",
    "@angular/forms": "4.0.0",
    "@angular/http": "4.0.0",
    "@angular/platform-browser": "4.0.0",
    "@angular/platform-browser-dynamic": "4.0.0",
    "@ionic/storage": "2.0.1",
    "ionic-angular": "3.0.1",
    "ionicons": "3.0.0",
    "rxjs": "5.1.1",
    "sw-toolbox": "3.4.0",
    "zone.js": "^0.8.4"
  "devDependencies": {
    "@ionic/app-scripts": "1.3.0",
    "typescript": "~2.2.1",
    "@ionic/cli-plugin-cordova": "0.0.12",
    "@ionic/cli-plugin-ionic-angular": "0.0.6"
  "version": "0.0.1",
  "description": "An Ionic project"

I’ll send an update shortly when I find the culprit.

The problem appears to be in "@ionic/app-scripts": "1.3.2".
Going from 1.3.0 to 1.3.2 produces this issue.

Confirmed that reverting to 1.3.0 removes the problem.
Someone else already reported this for Android in https://github.com/driftyco/ionic-app-scripts/issues/900.
I’m adding comments there as this seem to apply to all platforms.