Magento 2 - 'Area code not set:' after adding sample data

Try running this command first:

php bin/magento app:config:import

and then clear the cache and run setup:upgrade


Had the same issue and was able to resolve it.

Try running this command first:

php bin/magento sampledata:reset

And then re-run:

php bin/magento setup:upgrade

In case you had a memory exhausted error (which I encountered), try adding -dmemory_limit=6G on your setup:upgrade command.

php -dmemory_limit=6G bin/magento setup:upgrade

I faced this issue on Magento 2.4.2 after installing sample data and again uninstalling few selected sample data module using composer. To fix this issue, I manually changed app\etc\config.php by setting 0 instead of 1 for those extension which are not needed for Sample data (what I tried to remove using CLI command).