epi.globalcommandregistry cannot be resolved

Vote:
 

I get this error:

Error: Could not resolve dependency "epi.globalcommandregistry" (epi.dependency)
http://localhost:37006/EPiServer/Shell/7.12.0.0/ClientResources/epi/epi.js
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) {
				return;
			}

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

			// Remove the aspect handle.
			handle.remove();
		};

	// 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'?

#114951
Jan 05, 2015 14:02
Vote:
 

Instead of:

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

add it as an initializer in the clientModule section:

 <clientModule initializer="addon/initialize">



#114965
Edited, Jan 06, 2015 14:56
Vote:
 

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"?>
<module>
  <dojoModules>
    <add name="addon" path="/ClientResources/addon" />
  </dojoModules>

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

Any ideas or pointers to documentation?

#114980
Jan 07, 2015 9:16
Vote:
 

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: http://world.episerver.com/documentation/Items/Developers-Guide/EPiServer-CMS/75/Configuration/Configuring-moduleconfig/

#114984
Jan 07, 2015 10:40
Vote:
 

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?

#114991
Jan 07, 2015 13:41
Vote:
 

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

#114992
Jan 07, 2015 13:45
Vote:
 

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.

#114999
Jan 07, 2015 16:27
Vote:
 

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

/J

#117297
Feb 17, 2015 13:39
Vote:
 

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:

Modules.config:

(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)

#120438
Edited, Apr 16, 2015 22:51
Vote:
 
<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/">http://world.episerver.com/documentation/Items/Developers-Guide/EPiServer-CMS/8/Configuration/Configuring-moduleconfig/</a></p>
#120444
Apr 17, 2015 9:45
Vote:
 

Linus,

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!

#120471
Apr 17, 2015 16:50
Vote:
 

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

CustomCommandProvider.js:

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.

#120476
Edited, Apr 17, 2015 17:56
Vote:
 

I have updated the documentation to state the the client initializer should inherit from "epi/_Module": http://world.episerver.com/documentation/Items/Developers-Guide/EPiServer-CMS/8/Configuration/Configuring-moduleconfig/

#120646
Edited, Apr 22, 2015 7:47
Vote:
 
<p>Thanks Linus, this worked perfectly.</p> <p></p> <p>New Module File (PreviewLinkModule.js):</p> <p><img src="http://snag.gy/USOmm.jpg" width="584" alt="" height="241" /></p> <p></p> <p>Module.config:</p> <p><img src="http://snag.gy/rWHzt.jpg" 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>
#120705
Apr 22, 2015 19:49
Vote:
 
<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>
#120706
Apr 22, 2015 20:02
Vote:
 

Hi!

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">
    <moduleDependencies>
      <add dependency="CMS" type="RunAfter" />
    </moduleDependencies>
  </clientModule>
#120727
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.