[英]Laravel - /js/app.js not found 404 error
I installed Laravel 5.4
in my server /public_html/laravel/
folder.我在我的服务器
/public_html/laravel/
文件夹中安装了Laravel 5.4
。 When I access example.com/lavarel/public/
, it works.当我访问
example.com/lavarel/public/
时,它有效。
I copied all my compiled files in my local public/
folder into the example.com/lavarel/public/
.我将本地
public/
文件夹中的所有编译文件复制到example.com/lavarel/public/
中。 Then I add the <script src="/js/app.js"></script>
into my welcome.blade.php
:然后我将
<script src="/js/app.js"></script>
添加到我的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
:但是当我再次访问
example.com/lavarel/public/
时,出现404 error
:
GET example.com/js/app.js 404 (Not Found)
GET example.com/js/app.js 404(未找到)
if I change to <script src="/laravel/public/js/app.js"></script>
, I will get another 404 error
:如果我更改为
<script src="/laravel/public/js/app.js"></script>
,我将收到另一个404 error
:
GET example.com/laravel/public/laravel/public/js/app.js 404 (Not Found)
GET example.com/laravel/public/laravel/public/js/app.js 404(未找到)
How can I resolve this?我该如何解决这个问题?
I have same issue.我有同样的问题。 It simply solved by running:
它通过运行简单地解决了:
npm run dev
Step1: run the below command in your project.第 1 步:在您的项目中运行以下命令。
npm install
Step2: after successful npm modules installations run the below command.第 2 步:成功安装 npm 模块后,运行以下命令。
npm run dev
For better understanding visit laravel doc: https://laravel.com/docs/5.8/frontend为了更好地理解访问 laravel 文档: https ://laravel.com/docs/5.8/frontend
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.