5

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?

8
  • Is laravel allowed to read the files? If not this could also result in an 404 error. Commented Jul 28, 2017 at 7:38
  • 1
    When you tried with /laravel/public/...., are 100% sure you had the initial /? I don't see how you would have gotten that error message if you did. Commented Jul 28, 2017 at 7:41
  • check your console, from what url it is trying to load the js Commented Jul 28, 2017 at 7:49
  • @RAUSHANKUMAR The OP has included that in the question already. Commented Jul 28, 2017 at 8:00
  • I would recommend that you create a new vhost and have Laravel's public folder as the document root for the web server. Commented Jul 28, 2017 at 8:11

2 Answers 2

7

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

Sign up to request clarification or add additional context in comments.

1 Comment

any further explanations? any reference?
0

Step1: run the below command in your project.
npm install

Step2: after successful npm modules installations run the below command.
npm run dev

For better understanding visit laravel doc: https://laravel.com/docs/5.8/frontend

Comments

Your Answer

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.