SaaS CMS has officially launched! Learn more now.

epi.globalcommandregistry cannot be resolved


I get this error:

Error: Could not resolve dependency "epi.globalcommandregistry" (epi.dependency)
Line 2

while loading the website that has this module.config file:





and this initialize.js file:

require(['dojo/aspect', 'epi/dependency', 'addon/command/EditDynamicProperties'], function(aspect, dependency, EditDynamicProperties) {

	// summary:
	//		Initialize the addon by registering the command in the global toolbar.
	var handle,

		key = 'epi.cms.globalToolbar',

		registry = dependency.resolve('epi.globalcommandregistry'),

		callback = function(identifier, provider) {
			if(identifier !== key) {

			// When the command provider for the global toolbar is registered add our additional command.
			provider.addCommand(new EditDynamicProperties(), {
				showLabel: true

			// Remove the aspect handle.

	// Listen for when the global toolbar command provider is registered in the command provider registry.
	handle = aspect.after(registry, 'registerProvider', callback, true);

Any idea how to fix the issue? Should I use something different instead of 'epi.globalcommandregistry'?

Jan 05, 2015 14:02

Instead of:

    <add name="epi-cms.widgets.base" path="addon/initialize.js" resourceType="Script" />

add it as an initializer in the clientModule section:

 <clientModule initializer="addon/initialize">

Edited, Jan 06, 2015 14:56

This way the initialize.js file doesn't get loaded at all (not visible in Firebug list of scripts and no errors on Network console). My module.config now reads:

<?xml version="1.0" encoding="utf-8"?>
    <add name="addon" path="/ClientResources/addon" />

  <clientModule initializer="addon/initialize">
      <add dependency="Shell" />
      <add dependency="CMS" />

Any ideas or pointers to documentation?

Jan 07, 2015 9:16

It will only be loaded when the module is first initialized. You may need to restart your site.

Here is some documentation, see the "clientModule" section:

Jan 07, 2015 10:40

Then as I understand my initialize.js file will need to look like this:

define(["dojo"], function(dojo) {
    return dojo.declare([], {
        initialize: function() {
            // Do any custom module initialization here

which means that the 'dependency' object is missing. Of course I could add it the same way as in my original code, but then we are back to the original issue, aren't we? Shouldn't I somehow add a dependency on globalcommandregistry to my module?

Jan 07, 2015 13:41

No, I think the issue should be resolved by doing it the 'new' way by using an initializer.

Jan 07, 2015 13:45

The first problem that I cannot come over is that nothing seems to be loaded at all. I understand that just adding the above mentioned module.config file to my site should cause load attempt that would be visible in Network tab in Firebug (initialize.js). Is this correct? It does not happen in my case.

Jan 07, 2015 16:27

I'm experiencing the same thing, my js file doesnt load at all when I specify it as a clientmodule. Did you solve it?


Feb 17, 2015 13:39

Was anyone able to fix the issue where the file in the initializer of the clientModules element is never loaded? I am seeing this same issue with EPiServer 8.4.0.

File structure:


(I have also tried the non-shortened path in the initializer of "Client/Widgets/ProjectPreviewLink/RegisterCommand")

RegisterCommand.js (Is not even loaded, so it should not be relevant)

Any help is appreciated.

Update: The approach mentioned (here) seems to load the JS, but it does not support adding Shell/CMS as a dependency, which seems to cause the error originally reported in this thread (unable to resolve dependency to the globalcommandregistry)

Edited, Apr 16, 2015 22:51
<p>Hi!</p> <p>Try adding an initialize method to your class as well as defining the runAfter configuration as stated earlier in this thread. Official documentation can be found here:</p> <p><a href="/documentation/Items/Developers-Guide/EPiServer-CMS/8/Configuration/Configuring-moduleconfig/"></a></p>
Apr 17, 2015 9:45


I assume you meant I should add an initialize method to the RegisterCommand.js, but this isn't something that returns a class. It should just be running the JS in the file. It does not appear the JS is being precompiled and checked for an initialize method, meaning it would have to load the resource for it to realize there was not an initialize method. No network call is ever made in the browser for this file.

Here's how I added an initialize function anyway:

I've modified the module to have dependencies and a RunAfter, but again no luck.

Still looking for an answer. Thanks!

Apr 17, 2015 16:50

Edit: Please see Linus' response below for the correct answer.


The module.config:

It still appears to be ignoring the "initializer" attribute on the <clientModule> element. Making the script execute immediately as a required resource of the base clientModule with shell/cms dependencies allowed my code to execute at the right time to avoid the "epi.globalcommandregister cannot be resolved" error.

Edit: Please see Linus' response below for the correct answer.

Thanks for the help.

Edited, Apr 17, 2015 17:56

I have updated the documentation to state the the client initializer should inherit from "epi/_Module":

Edited, Apr 22, 2015 7:47
<p>Thanks Linus, this worked perfectly.</p> <p></p> <p>New Module File (PreviewLinkModule.js):</p> <p><img src="" width="584" alt="" height="241" /></p> <p></p> <p>Module.config:</p> <p><img src="" width="580" alt="" height="144" /></p> <p></p> <p>Note: The requiredResource tag only exists now for a CSS file associated with my module. The js file with the "Script" resource type from my previous post was removed since the initializer attribute is now working.</p>
Apr 22, 2015 19:49
<p>One more question: In my last post, you'll notice BOTH module dependencies Shell/Cms have type="RunAfter". If I remove&nbsp;<strong></strong><strong>either</strong> of the type="RunAfter" attributes, the module does not seem to load.</p> <p></p> <p>Any ideas?</p>
Apr 22, 2015 20:02


I don't think that you have to list both as dependencies since CMS takes a dependency to Shell. This is how I've specified the modules I've done:

  <clientModule initializer="instantTemplates.TemplateModule">
      <add dependency="CMS" type="RunAfter" />
Apr 23, 2015 13:02
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.