If you encounter a problem with an external NPM package in an Ember project, make sure everyone is running the correct package version.
Today, one of our web application developers was helping a new colleague set up our Ember project and found an issue with one of the NPM packages. We use ember-simple-auth for authenticating users in the app and we didn’t pin it to the exact version in the
package.json file - it was
^1.1.0 in our case. When the new team member ran
npm install, he got a newer version (
1.2.0) - different from what everyone else had. The authors of that new version added ember-cli-import-polyfill, which broke imports in our add-ons.
We have a specific use case as we share common code between the app and our chrome extension using
ember addons. These addons contain some other 3rd party add-ons and
ember-cli-import-polyfill broke imports for us. We immediately reported that on the
ember-simple-auth issue page. It turned out that the import polyfill is for Ember apps, not Ember add-ons. Hopefully it will be removed from
ember-simple-auth on the next release - for now we pinned it to
1.1.0 in the repo.
The moral of today’s battle: always pin external NPM package’s version in your
package.json file :).
We hope you enjoyed today’s Developers’ Notes, delivered for your reading pleasure by Łukasz, iRonin’s Web Application Development Team Leader. There’s more coming soon, so stay tuned!