Magento – Magento 2: add js file, but I can’t find the file in static folder

customjs-cssmagento2requirejs

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

Best Answer

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.

Related Topic