Error #1 - missing polyfill
* Note: The following error does NOT occur when running the ionic serve command so you are lulled into a false sense of security by seeing your code 'work'.
Having recently upgraded to ionic 3.7 I encountered the following error while attempting to build a project for iOS with the NPM firebase package installed:
Error: ./node_modules/firebase/utils/promise.js Module not found: Error: Can't resolve 'promise-polyfill' in ‘/projects/ionic-fire/node_modules/firebase/utils' resolve 'promise-polyfill' in '/projects/ionic-fire/node_modules/firebase/utils' Parsed request is a module using description file: /projects/ionic-fire/node_modules/firebase/package.json (relative path: ./utils) Field 'browser' doesn't contain a valid alias configuration after using description file: /projects/ionic-fire/node_modules/firebase/package.json (relative path: ./utils) resolve as module looking for modules in /projects/ionic-fire/node_modules using description file: /projects/ionic-fire/package.json (relative path: ./node_modules) Field 'browser' doesn't contain a valid alias configuration after using description file: /projects/ionic-fire/package.json (relative path: ./node_modules) using description file: /projects/ionic-fire/package.json (relative path: ./node_modules/promise-polyfill) no extension Field 'browser' doesn't contain a valid alias configuration /projects/ionic-fire/node_modules/promise-polyfill doesn't exist .ts Field 'browser' doesn't contain a valid alias configuration /projects/ionic-fire/node_modules/promise-polyfill.ts doesn't exist .js Field 'browser' doesn't contain a valid alias configuration /projects/ionic-fire/node_modules/promise-polyfill.js doesn't exist .json Field 'browser' doesn't contain a valid alias configuration /projects/ionic-fire/node_modules/promise-polyfill.json doesn't exist as directory /projects/ionic-fire/node_modules/promise-polyfill doesn't exist [/projects/ionic-fire/node_modules/promise-polyfill] [/projects/ionic-fire/node_modules/promise-polyfill.ts] [/projects/ionic-fire/node_modules/promise-polyfill.js] [/projects/ionic-fire/node_modules/promise-polyfill.json] [/projects/ionic-fire/node_modules/promise-polyfill] @ ./node_modules/firebase/utils/promise.js 14:76-103 @ ./node_modules/firebase/app/firebase_app.js @ ./node_modules/firebase/app.js @ ./node_modules/firebase/firebase-browser.js @ ./src/app/app.component.ts @ ./src/app/app.module.ts @ ./src/app/main.ts
Although a little daunting at first the error message does provide one very important clue as to why the build breaks - the required promise-polyfill module doesn't appear to be installed.
Unfortunately this isn't a new or isolated issue as previous threads have been posted on the same subject.
Thankfully fixing this is as simple as running the following command:
npm install promise-polyfill --save-exact
Why the promise-polyfill isn't added as a dependency to the project's package.json file by default I don't know (particularly as this is not a new issue) but thankfully the previous npm command fixes the issue entirely.
Error #2 - ionic resources error
Similarly, after upgrading to ionic 3.7, I initially received the following error while attempting to run the ionic resources command:
Error: Error: getaddrinfo ENOTFOUND github.com github.com:443
It's important to note that I wasn't connecting to a network via a proxy (as some developers have noted is a common culprit for receiving this error message) while running the ionic resources command.
After some initial bafflement and much internet browsing (where would developers be without Google and Stack Overflow?) I found running the following command resolved the error:
npm -g cache clean
There's no two ways about it: software bugs SUCK.
Ridiculous amounts of time can be lost trying to fix issues that shouldn't even exist but hey, welcome to the world of software development!
Hopefully the above 'solutions' might prove helpful to ionic developers out there who are struggling with the same issues so please feel free to share your comments, thoughts and suggestions in the comments area below.
I explore solutions to other Ionic framework related errors within my e-book featured below and if you're interested in learning more about my e-books please sign up to my FREE mailing list where you can receive updates on current/forthcoming e-books and blog articles.