Problem/Motivation

Attempted to update to 4.3.1, but getting "missing or invalid module" error for js_cookie. The 4.3.1 update switches from js_cookie to localStorage, and running 'composer update' removes js_cookie. But I guess that doesn't remove the config and so you can't run update.php? Or something? Unclear what I'm supposed to do besides run 'composer update'.

Comments

jwineichen created an issue. See original summary.

joelpittet’s picture

Oh yes that is annoying. I have run into that with transitive dependencies. I tend to “hoist” all the Drupal/ packages to the root composer.json (sorry replying from phone, but have a script I can share)

In any case, composer require Drupal/js_cookie will get you over the hump, then you can decide to uninstall it at your convenience

joelpittet’s picture

If you have composer and jq this is the one-liner

composer show --format=json | jq -r '.installed[] | select(."direct-dependency" == false and (.name | startswith("drupal/")) and .name != "drupal/core") | .name' | xargs -I {} composer require {}

I'm on macOS so that works for me... let me know if this helps @jwineichen

Explanation

  • composer show --format=json: Lists all installed packages in JSON format.
  • jq -r '...': Filters the JSON to find packages where:
  • "direct-dependency" is false (meaning they are transitive).
  • The name starts with drupal/.
  • The name is not drupal/core.
  • xargs -I {} composer require {}: Runs composer require for each identified package to promote it to a direct dependency.
jwineichen’s picture

Status: Active » Fixed

That resolved it; thanks!

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

joelpittet’s picture

I am glad that helped!

The script is great but there are some false positives you might run into like drupal/chosen has a library drupal/chosen_lib that is not a module but uses the same drupal/ vendor, for example. Mileage may vary.