I have installed the magento 2.2.1 but on deploying static content it is giving following error

    PHP Fatal error:  Uncaught Error: Call to a member function getPackage() on null in /var/www/html/unicorn-magento/vendor/magento/module-deploy/Package/Processor/PostProcessor/CssUrls.php:215
Stack trace:
#0 /var/www/html/unicorn-magento/vendor/magento/module-deploy/Package/Processor/PostProcessor/CssUrls.php(109): Magento\Deploy\Package\Processor\PostProcessor\CssUrls->getValidExternalUrl('{{base_url_path...', Object(Magento\Deploy\Package\Package))
#1 /var/www/html/unicorn-magento/vendor/magento/module-deploy/Package/Processor/PostProcessor/CssUrls.php(80): Magento\Deploy\Package\Processor\PostProcessor\CssUrls->parseCss(Array, 'css/email-inlin...', 'frontend/Custom...', '@import url("{{...', Object(Magento\Deploy\Package\Package))
#2 /var/www/html/unicorn-magento/vendor/magento/module-deploy/Service/DeployPackage.php(147): Magento\Deploy\Package\Processor\PostProcessor\CssUrls->process(Object(Magento\Deploy\Package\Package), Array)
#3 /var/www/html/unicorn-magento/vendor/magento/module-deploy/Service/DeployPackage.php(103):  in /var/www/html/unicorn-magento/vendor/magento/module-deploy/Package/Processor/PostProcessor/CssUrls.php on line 215

I have removed view_processed content, pub/satatic and tried multiple times but this error is showing. Please help to resolve this. Thanks

  • Magento tried to run getPackage function on some object which is equal null. Try to find out why this object is null using xdebug... Feb 22, 2018 at 21:29
  • @Nitin Pawar did you find out the reason?
    – M.Elwan
    May 29, 2018 at 11:21

4 Answers 4


This is already answered here by @MateuszLerczak

I am quoting the relevant part from the answer below:

Workaround for that is remove generated data before deploy. If var/view_preprocessed exists magento using data from this dir.

rm -rf pub/static/* var/view_preprocessed/pub/*

php bin/magento setup:static-content:deploy -f en_US

Also see this GitHub thread for more details


It seems to be a magento bug :-( . The way to reverse it is the following (I know this is not a solution) but it will help to have the site working again:

On command line:

Magento ≥ 2.2

php bin/magento config:set dev/css/minify_files 0

phpbin/magento cache:clean

Magento < 2.2

On DB (mysql client) execute:

UPDATE core_config_data SET value = 0 WHERE path = 'dev/css/minify_files'

bin/magento cache:clean

Now, you can compile again.


issue 11372 throwing error:

Fatal error: Uncaught Error: Call to a member function getPackage() on null in /srv/magento2/vendor/magento/module-deploy/Package/Processor/PostProcessor/CssUrls.php on line 217

Error: Call to a member function getPackage() on null in /srv/magento2/vendor/magento/module-deploy/Package/Processor/PostProcessor/CssUrls.php on line 217

Full steps to deploy static content on system:

Remove cache

This is caused by previously genereated cache on var/view_preprocessed, to fix this we need to remove cache:

rm -rf pub/static/* 
rm -rf var/view_preprocessed/pub

Deploy static content for backend

php bin/magento setup:static-content:deploy -f en_US -t Magento/backend

Deploy static content for frontend

php bin/magento setup:static-content:deploy -f en_US -t OurTheme/themeName

Clearing the existing static content did not help for me, but deploying with standard strategy, instead of quick did:

bin/magento setup:static-content:deploy -f -j 4 -s standard

Edit: it looks like the error did not go away, and the reason it didn't fail has nothing to do with the strategy. Repeated tests show that if deploying using multiple jobs (-j 4) the error is still there but it doesn't stop the deployment process.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.