首页 > 解决方案 > Laravel newly added javascript files give an error net::ERR_ABORTED 404 (Not Found)

问题描述

In my laravel application, it gives an error with a net:: ERR_ABORTED 404 (Not Found). I have added the javascript files into the

resources\assets\js\customjsfile.js

.

And I'm calling the file like this.

<script src="{{ asset('js/customjsfile.js')  }}"></script>

Other js files such as app.js are loading.

标签: javascriptlaravellaravel-5

解决方案


asset() function takes path from the /public folder by default. if you are using laravel mix then you should update your webpack.mix.js file otherwise you can directly put the file in /pubilc/js folder.

In webpack.mix.js:

mix.js('resources/js/customfile.js', 'public/js');

Then run

npm run dev // for development
npm run production // for production

for this

"Other js files such as app.js are loading."

app.js file is already defined in the webpack.mix.js


推荐阅读