0

I've added

dependencies:
 - core/jquery
 - core/drupal

to mymodule.info.yml

(where mymodule is my module name).

How do I ensure Drupal "sees" these new dependencies?

For example, can I clear the cache, drush cr ?

Or is there another drush command to run or something else to do?

When does Drupal read the info.yml file? When module enabled - yes - but what other times?

I would prefer a command to get it to read that file rather than uninstall my module and reenable my module as this could be inconvenient with regard to config/content needing to be re-setup.

Thank you.

Background

I'm working on solving a problem where anonymous users see Uncaught ReferenceError: Drupal is not defined in console, based on a solution that adds the dependencies I mentioned above: Anonymous Users See Uncaught ReferenceError: Drupal is not defined In console.

Potentially related: jQuery not Loading for “Anonymous” Users

6
  • Are missing another space before the two -? There's only one space, right?
    – leymannx
    Commented Oct 21, 2020 at 14:39
  • Do you mean there are too many spaces on the line before or after the - or do you mean there needs to be an empty line between the 2 dependenices, @leymannx? (thank you for taking the time to look, please let me know your thoughts) Commented Oct 21, 2020 at 14:49
  • 1
    Before each - there seems to be one space too few. There need to be two spaces before each -. Simply look in other modules in core to compare.
    – leymannx
    Commented Oct 21, 2020 at 14:58
  • +1 Thanks - do you know when, apart from enabling the module, Drupal reads the info.yml file (as per my question)? Also - I notice that some dependencies use a colon, as in drupal:file - should I do the same, instead of the slash? Commented Oct 21, 2020 at 15:06
  • 1
    hook_requirements() has 3 phases : install (called while the module is installed), runtime (called during regular use of the website), update (called while the update.php is being executed). I am not sure but I guess running an update or cron might read the requirements in .info files.
    – MacSim
    Commented Oct 21, 2020 at 15:14

1 Answer 1

1

I think you are mixing dependencies to modules with dependency to libraries. Your code adds a PHP module dependency to core/jquery, and I don't know any module of this name.

(When in module.info.yml)
If you want to add a (JS or CSS) library dependency, use the libraries: key and not dependencies:

(When in module.libraries.yml)
Remember that just defining a library does not automatically load it, you still must add it in module.info (or load it dynamically)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.