Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel - /js/app.js not found 404 error

I installed Laravel 5.4 in my server /public_html/laravel/ folder. When I access example.com/lavarel/public/, it works.

I copied all my compiled files in my local public/ folder into the example.com/lavarel/public/. Then I add the <script src="/js/app.js"></script> into my welcome.blade.php:

<!doctype html>
<html lang="{{ config('app.locale') }}">
    <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <meta name="csrf-token" content="{{ csrf_token() }}">
        <title>Laravel</title>
        <!-- UIkit CSS -->
        <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/uikit/3.0.0-beta.25/css/uikit.min.css" />
        <!-- <link rel="stylesheet" href="assets/sass/uikit.css" /> -->

        <!-- jQuery is required -->
        <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>

        <!-- UIkit JS -->
        <script src="https://cdnjs.cloudflare.com/ajax/libs/uikit/3.0.0-beta.25/js/uikit.min.js"></script>
        <script src="https://cdnjs.cloudflare.com/ajax/libs/uikit/3.0.0-beta.25/js/uikit-icons.min.js"></script>
        <!-- Fonts -->
        <link href="https://fonts.googleapis.com/css?family=Raleway:100,600" rel="stylesheet" type="text/css">

    </head>
    <body>
        <div id="app" style="background:#666;height: 100vh;">

            <router-view></router-view>
        </div>

         <script src="/js/app.js"></script>
    </body>
</html>

But when I go to example.com/lavarel/public/ again, I got 404 error:

GET example.com/js/app.js 404 (Not Found)

if I change to <script src="/laravel/public/js/app.js"></script>, I will get another 404 error:

GET example.com/laravel/public/laravel/public/js/app.js 404 (Not Found)

How can I resolve this?

like image 344
sooon Avatar asked Mar 08 '23 12:03

sooon


1 Answers

I have same issue. It simply solved by running:
npm run dev

like image 63
William Fisher Avatar answered Mar 20 '23 08:03

William Fisher