setup:di:在Magento 2中编译和更改模式到生产失败

When I try to change mode from developer to production a non-zero exit code is returned. I figured out it was not during deployment of static content, it was during compilation. memory_limit is 2000M. I checked php bin/magento setup:di:compile and found out that it stops and exits compilation at Repositories code generation... without showing any error. I migrated the site to localhost, and now it successfully compiles and goes to production mode.

Why is it working in localhost, but fails in the online server?

Hi use this command to deploy when getting memory-limit problem.

php -dmemory_limit=6G bin/magento setup:static-content:deploy

Open admin : store> configuration > Advanced > Developer >Frontend Development Workflow > Workflow type > Server Side less compilation then

Use below commonds for set production mode.

rm -rf var/*
rm -rf pub/static/*
php bin/magento deploy:mode:set production --skip-compilation
php -dmemory_limit=6G bin/magento setup:static-content:deploy
chmod -R 7777 var pub/static