in my case i have added a less file to compile a css file in my Base Module , but after I run this command "bin/magento setup:static-content:deploy -f" an error was occured like belllwo

  Cannot read contents from file "/var/www/html/myproject/pub/static/frontend/Magento/blank/en_US/Mymodule_Base/style.css" Warning!file_get_contents(  
  /var/www/html/myproject/pub/static/frontend/Magento/blank/en_US/Mymodule_Base/style.css): failed to open stream: No such file or directory  

Ps : i have already grant all privileges with chmod 777 ans also with chown

can anyone help me please to run the command correctly

3 Answers 3


In most cases this happens due to empty less/css files.

Check if the file style.css or style.less located in the frontend directory of Mymodule_Base module is not empty. Add some css there. Then run

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

and then run static content deployment again.


these 2 lines may help:

find var generated vendor pub/static pub/media app/etc -type d -exec chmod g+ws {} +

assuming www-data is your server group

chown -R :www-data .

references: https://devdocs.magento.com/guides/v2.4/install-gde/prereq/file-system-perms.html#perms-set-two-users


Following command will help you for sure.

chmod -R 777 var pub generated 
php bin/magento setup:upgrade && php bin/magento setup:static-content:deploy en_US -f

If this helps you then hit like and accept as answer.

Thank you,
Hiren Patel

This site is temporarily in read-only mode and not accepting new answers.

Not the answer you're looking for? Browse other questions tagged .