Site editor

List all importable modules in an Ember project


by Ryan Toronto

Have you ever

  1. forgotten the absolute path to /config/environment.js?
  2. wondered what files an addon adds to your import path?
  3. gotten an error that looks like this?
Error: Could not find module 'some-addon/foo' imported from
'embermap-cms/pods/components/date-picker/component'

Here's a trick that will list every importable module in your Ember app. In the console, type

requirejs.entries

This will show you an object whose keys contain all importable paths.

If I'm looking for something specific (say, all modules provided by the ember-modal-dialog addon), I might use Object.keys and write a simple filter:

Object.keys(requirejs.entries).filter(n => n.includes("ember-modal-dialog"))

Just be aware that requirejs.entries is considered private, so you shouldn't write any code that depends on it. Instead, think of it as a useful debugging tool.

Questions?

us, or ask in #media on Discord