Registry /
devops / ember-cli-version-checker
The `ember-cli-version-checker` package is a fundamental utility for Ember CLI addon authors. It provides a robust mechanism to programmatically determine the installed versions of NPM or (historically) Bower packages within a consuming Ember application's dependency tree. This allows addons to implement conditional logic, such as providing different features, templates, or polyfills, based on the host application's Ember CLI or Ember.js version, thus ensuring broad compatibility. The current stable version is 5.1.2, with releases occurring on an as-needed basis for bug fixes and minor enhancements rather than a fixed cadence. Its core differentiator lies in its deep integration with the Ember CLI project context, simplifying complex semver comparisons for specific dependencies.
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslnode 18–226 runs
build_error
glibcnode 18–226 runs
build_error
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
Ember CLI addons are typically CommonJS modules. Using `require` is the standard pattern. Direct ESM import is not commonly supported or recommended in this context.
const VersionChecker = require('ember-cli-version-checker');
Methods are accessed on an instance of VersionChecker, which must be initialized with the `this.project` object from an Ember CLI addon context.
const checker = new VersionChecker(this.project);
const dep = checker.for('ember-cli');
if (dep.gte('2.0.0')) { /* ... */ }
Demonstrates initializing `VersionChecker` within an Ember CLI addon's hooks, asserting minimum dependency versions, and conditionally loading resources based on the host application's Ember.js version.
const path = require('path');
const VersionChecker = require('ember-cli-version-checker');
// This code would typically reside in an Ember CLI addon's index.js file
// inside the module.exports object.
module.exports = {
name: 'my-awesome-addon',
init() {
this._super.init.apply(this, arguments);
const checker = new VersionChecker(this.project);
// Assert a minimum Ember CLI version
checker.for('ember-cli').assertAbove('2.13.0', '`my-awesome-addon` requires Ember CLI >= 2.13.0');
const emberDep = checker.for('ember');
if (!emberDep.exists()) {
console.warn('Ember.js not found in project dependencies. This addon may not function correctly.');
}
console.log(`Ember version: ${emberDep.version || 'N/A'}`);
},
treeForAddonTemplates(tree) {
const checker = new VersionChecker(this.project);
const emberDep = checker.for('ember');
const baseTemplatesPath = path.join(this.root, 'addon/templates');
// Conditionally provide templates based on Ember version
if (emberDep.satisfies('>= 3.0.0')) {
return this.treeGenerator(path.join(baseTemplatesPath, 'modern'));
} else if (emberDep.satisfies('>= 2.0.0')) {
return this.treeGenerator(path.join(baseTemplatesPath, 'classic'));
} else {
// Fallback for older Ember versions or non-existent Ember
return this.treeGenerator(path.join(baseTemplatesPath, 'legacy'));
}
}
};
Upgrade
Version history
Breaking-change detection hasn't run for this library yet.
Audit
Security & dependencies
CVE tracking and dependency tree are planned for a later release.