1

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

Vaibhav Ahalpara
5,2854 gold badges43 silver badges81 bronze badges
asked Jun 27, 2016 at 8:29
3
  • 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? Commented Sep 23, 2017 at 16:24
  • Please make sure that you follow all the required steps in this tutorial. devdocs.magento.com/videos/fundamentals/add-a-javascript-module Commented Oct 13, 2018 at 11:18
  • Have you added correct file path on requirejs file? Commented Jan 16, 2022 at 14:00

3 Answers 3

0

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.

answered Jun 27, 2016 at 8:40
2
  • 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. Commented Sep 23, 2017 at 16:15
0

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.

answered Mar 2, 2017 at 16:59
0

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

YourModule/view/frontend/web/js/materialize.js
-> 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.
Teja Bhagavan Kollepara
3,8275 gold badges33 silver badges69 bronze badges
answered Jun 8, 2017 at 11:01

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.