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
Comment #2
joelpittetOh 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
Comment #3
joelpittetIf you have composer and jq this is the one-liner
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"isfalse(meaning they are transitive).drupal/.drupal/core.xargs -I {} composer require {}: Runscomposer requirefor each identified package to promote it to a direct dependency.Comment #4
jwineichen commentedThat resolved it; thanks!
Comment #6
joelpittetI am glad that helped!
The script is great but there are some false positives you might run into like
drupal/chosenhas a librarydrupal/chosen_libthat is not a module but uses the samedrupal/vendor, for example. Mileage may vary.