I add js file in my module using the requirejs, but the requirejs can't load the file and i get this error:

require.js:1895 GET (my_ip)/magento2/pub/static/frontend/Magento/SaturTheme/it_IT/SliderHome/js/materialize.js

If I open this link I get this stacktrace error:

The "/var/www/html/magento2/" file doesn't exist or not a file

    0 /var/www/html/magento2/vendor/magento/framework/Filesystem/Directory/Write.php(146): Magento\Framework\Filesystem\Directory\Write->assertIsFile(false)
    1 /var/www/html/magento2/vendor/magento/framework/App/View/Asset/MaterializationStrategy/Symlink.php(30): Magento\Framework\Filesystem\Directory\Write->createSymlink(false, 'frontend/Magent...', Object(Magento\Framework\Filesystem\Directory\Write))
    2 /var/www/html/magento2/vendor/magento/framework/App/View/Asset/Publisher.php(66): Magento\Framework\App\View\Asset\MaterializationStrategy\Symlink->publishFile(Object(Magento\Framework\Filesystem\Directory\Write), Object(Magento\Framework\Filesystem\Directory\Write), false, 'frontend/Magent...')
    3 /var/www/html/magento2/vendor/magento/framework/App/View/Asset/Publisher.php(50): Magento\Framework\App\View\Asset\Publisher->publishAsset(Object(Magento\Framework\View\Asset\File))
    4 /var/www/html/magento2/vendor/magento/framework/App/StaticResource.php(109): Magento\Framework\App\View\Asset\Publisher->publish(Object(Magento\Framework\View\Asset\File))
    5 /var/www/html/magento2/vendor/magento/framework/App/Bootstrap.php(258): Magento\Framework\App\StaticResource->launch()
    6 /var/www/html/magento2/pub/static.php(13): Magento\Framework\App\Bootstrap->run(Object(Magento\Framework\App\StaticResource))
    7 {main}

I tried also to run this command, but nothing change:

php bin/magento --ansi setup:static-content:deploy it_IT

  • hey, can you give a bit more details please? 1. Could you share the folder structure of your module and the requirers-config.js file content? 2. How are you calling this js file. from a phtml?
    – Asrar
    Commented Sep 23, 2017 at 16:24
  • Have you added correct file path on requirejs file? Commented Jan 16, 2022 at 14:00

4 Answers 4


you have to first delete pub/static folder all content.

Run Command

php bin/magento setup:static-content:deploy

Remove var folder from root.

Clear Browser cache.

Refresh page your js file is getting inside browser.

  • 2
    you shouldn't remove .htaccess if you are using apache Commented Jan 13, 2017 at 15:45
  • No, the whole pub/static folder should never be removed.
    – Asrar
    Commented Sep 23, 2017 at 16:15

Can you add your JS code (or at least the require JS dependency part) please? If your file name/paths are correct this should help:

  1. Delete pub/static/frontend
  2. Delete pub/static/requirejs
  3. Delete var/view_preprocessed
  4. Clear Magento caches

Do not delete the whole pub/static folder or you will run into problems.

Also if you are in developer mode (you should be for development) running the static-content deploy command is a waste of time as the files are symlinked anyway.


You need to make sure that your module's js file placed as per below location, If not then correct.


-> After that you should run deploy command for your language (in case not in en_US)
php bin/magento setup:static-content:deploy it_IT

-> Flush cache and set proper permission to var and pub/static directory.

Please make sure that you follow all the required steps in this tutorial. https://devdocs.magento.com/videos/fundamentals/add-a-javascript-module/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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