composer require implicitly calls "composer update", but there's no way to pass through a "--no-dev" flag. composer require --no-update <module> && composer update --no-dev <module> is a workaround, but very clumsy.
The composer update behaviour was changed at https://github.com/composer/composer/pull/1644.
Context is that we want to promote "composer require" as a preferred way to install modules, but our dev requirements only apply to a small fraction of our devs (e.g. those running behaviour tests through behat)
The problem is if you run update with --no-dev, then you can not install with --dev anymore since the composer.lock is incomplete. Also, the require command's "--dev" argument is a bit different right now it just defines whether the required packages goes in the require or require-dev block. That's why there is no --no-dev flag, because it would be even more confusing.
IMO all devs should just run install and update and require in dev mode. It makes no sense not to. If only a few devs run the behat tests so it goes, they'll have a few extra files on disk, no harm done.
If you really don't want to though, and like to generate incomplete lock files, you can do: composer require --no-update foo/bar && composer update --no-dev.
Apparently there's an --update-no-dev option these days.
Most helpful comment
Apparently there's an
--update-no-devoption these days.