Are your icons, images & javascript files missing from the frontend after applying the update command in Magento 2.4.1?
This guide will help you.
This can happen when we use any incorrect command to update the Magento.
Here at Ibmi Media, as part of our Server Management Services, we regularly help our Customers to resolve Magento errors for Magento site owners.
In this context, we shall look into how to tackle this Magento problem.
Recently, one of our customers approached us telling us that all the icons, images, and javascript files stopped displaying in the Magento website frontend.
This happened after applying the update command in Magento 2.4.1.
Here is the command he used for upgrading the Magento version:
php magento setup:install
As a result of the above command, the below message appears:
[Progress: 1347 / 1347]
[SUCCESS]: Magento installation complete.
[SUCCESS]: Magento Admin URI: /admin_1d6ja1
Then after the installation, the images, icon, and javascript files didn’t display properly in the frontend of the website.
Now, let us see how our Support Experts resolve this Magento problem.
i. First, we make sure if the customer was in a production mode or in a developer mode.
ii. Since he was in production mode, we suggest running the below command to upgrade the Magento:
$ php bin/magento setup:upgrade --keep-generated
Here, in the above command, the –keep-generated is an optional argument that does not update static view files.
We can use it only in production mode. It should not be used in developer mode.
iii. Finally, after that, we can clean the cache.
For that, we run the below command:
$ bin/magento cache:clean
This article covers methods to resolve Magento error related to with icons, images, and javascript files missing from frontend. Basically, icons, images, and javascript files might not appear if we use the wrong Magento update command to upgrade the version.
If you are in production mode, and are running setup:upgrade and you don't want regenerate static content because there is no need to, then you can use the following:
php bin/magento setup:upgrade --keep-generated
--keep-generated is an optional argument that does not update static view files.
It should be used only in production mode.
It should not be used in developer mode.
Solutions for the issue where stylesheets and images do not load after installing Magento ?
The following are possible solutions depending on the software you use and the cause of the problem:
If you are using the Apache web server, verify your server rewrites setting and your Magento server's base URL and try again. If you set up the Apache AllowOverride directive incorrectly, the static files are not served from the correct location.
If you are using the nginx web server, be sure to configure a virtual host file. The nginx virtual host file must meet the following criteria:
The include directive must point to the sample nginx configuration file in your Magento installation directory. For example:
include /var/www/html/magento2/nginx.conf.sample;
The server_name directive must match the base URL you specified when installing Magento. For example:
server_name ip_address;
If the Magento application is in production mode, try deploying static view files using the command magento setup:static-content:deploy.