2

I'm running Magento 2.2.2 in developer mode. When I try to display a page, the static files are not available unless I remove all the pub folder content with rm -R pub/static/* Once it's done, the static files are available only one time. If I refresh the page, they're gone :

Loading failed for the <script> with source “pub/static/adminhtml/Magento/backend/en_US/requirejs/require.js”.

(same error for several other js and css files)

I tried setup:static-content:deploy but it doesn't fix the issue. After working on it for several hours, my guess is that something is wrong with the symlink but I don't get where, when I use readlink the path is correct : lib/web/requirejs/require.js.

Any help would be greatly appreciated.

2
1

When You remove pub/static/* folder, You removed .htaccess file.

Keep in mind never delete pub/static/.htaccess

You can download .htaccess file from the official Magento 2 repository. That will solve your problem.

3
  • 1
    Actually, ´rm -R pub/static/*´ doesn't remove the .htaccess (which is hidden), read here : devdocs.magento.com/guides/v2.0/howdoi/clean_static_cache.html However, I tried to replace the .htaccess with the one from the M2 repository, but it doesn't solve the problem.
    – Manu
    Jan 29 '18 at 14:47
  • Please check front folder static folder after deploy content Jan 29 '18 at 14:49
  • Checked : same problem with the frontend files.
    – Manu
    Jan 29 '18 at 18:10
0

first remove all files or folders inside : 1)pub/static (except .htaccess file inside static folder) 2) var/cache

than run commands in following order :

php bin/magento cache:flush
php bin/magento cache:clean 
php bin/magento indexer:reindex
php bin/magento setup:di:compile
php bin/magento deploy:mode:set developer
php bin/magento setup:upgrade
php bin/magento cron:run
php bin/magento setup:static-content:deploy

and if you will still face error , set permissions : Permission commands:

---------------------------------------
find . -type f -exec chmod 644 {} ;                        // 644 permission for files
find . -type d -exec chmod 755 {} ;                        // 755 permission for directory  
find ./var -type d -exec chmod 777 {} ;                // 777 permission for var folder     
find ./pub/media -type d -exec chmod 777 {} ;
find ./pub/static -type d -exec chmod 777 {} ;
chmod 777 ./app/etc
chmod 644 ./app/etc/*.xml
-----------------------------------------------

also find "Symlink" keyword in app/etc/di.xml , remove it with Copy.

1
  • I have run all the commands you advised with no result. I have found and deleted <item name="view_preprocessed" xsi:type="object">Magento\Framework\App\View\Asset\MaterializationStrategy\Symlink</item> in app/etc/di.xml with no result either. Any other idea ? Thanks.
    – Manu
    Jan 29 '18 at 18:02

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.