我有一个节点js项目,并为管理员添加了一个模板。在我的本地服务器上,它显示一切正常,但是当我将它推送到我的web服务器上时,它不会加载管理页面并在控制台中显示几个错误。这些错误未在开发系统Web浏览器控制台中显示。
错误是:
Refused to apply style from 'http://www.skillbuild.pro/admin/assets/node_modules/morrisjs/morris.css' because its MIME type ('text/html') is not a supported stylesheet MIME type, and strict MIME checking is enabled.
它还显示几个js文件不是fount(404错误),而这些文件存在于相关文件夹中。
以下是我的主管部分:
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<!-- Tell the browser to be responsive to screen width -->
<meta name="viewport" content="width=device-width, initial-scale=1"> {{!--
<meta http-equiv="content-type" content="text/html; charset=UTF-8" /> --}}
<meta name="description" content="">
<meta name="author" content="">
<!-- Favicon icon -->
<link rel="icon" type="image/png" sizes="16x16" href="../assets/images/favicon.png">
<title>Elite Admin Template - The Ultimate Multipurpose admin template</title>
<!-- This page CSS -->
<!-- chartist CSS -->
<link href="/admin/assets/node_modules/morrisjs/morris.css" rel="stylesheet" type="text/css">
<!--Toaster Popup message CSS -->
<link href="/admin/assets/node_modules/toast-master/css/jquery.toast.css" rel="stylesheet" type="text/css">
<!-- Morris CSS -->
<link href="/admin/assets/node_modules/morrisjs/morris.css" rel="stylesheet" type="text/css">
<!-- Custom CSS -->
<link href="/admin/dist/css/style.min.css" rel="stylesheet" type="text/css">
<!-- Dashboard 1 Page CSS -->
<link href="/admin/dist/css/pages/dashboard1.css" rel="stylesheet" type="text/css">
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
<script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
这些是我的页脚部分,其中调用了js文件:
<!-- All Jquery -->
<!-- ============================================================== -->
<script src="/admin/assets/node_modules/jquery/jquery-3.2.1.min.js" type="application/javascript"></script>
<!-- Bootstrap popper Core JavaScript -->
<script src="/admin/assets/node_modules/popper/popper.min.js" type="application/javascript"></script>
<script src="/admin/assets/node_modules/bootstrap/dist/js/bootstrap.min.js" type="application/javascript"></script>
<!-- slimscrollbar scrollbar JavaScript -->
<script src="/admin/dist/js/perfect-scrollbar.jquery.min.js" type="application/javascript"></script>
<!--Wave Effects -->
<script src="/admin/dist/js/waves.js" type="application/javascript"></script>
<!--Menu sidebar -->
<script src="/admin/dist/js/sidebarmenu.js" type="application/javascript"></script>
<!--Custom JavaScript -->
<script src="/admin/dist/js/custom.min.js" type="application/javascript"></script>
<!-- ============================================================== -->
<!-- This page plugins -->
<!-- ============================================================== -->
<!--morris JavaScript -->
<script src="/admin/assets/node_modules/raphael/raphael-min.js" type="application/javascript"></script>
<script src="/admin/assets/node_modules/morrisjs/morris.min.js" type="application/javascript"></script>
<script src="/admin/assets/node_modules/jquery-sparkline/jquery.sparkline.min.js" type="application/javascript"></script>
<!-- Popup message jquery -->
<script src="/admin/assets/node_modules/toast-master/js/jquery.toast.js" type="application/javascript"></script>
<!-- Chart JS -->
<script src="/admin/dist/js/dashboard1.js" type="application/javascript"></script>
在我的server.js文件中我定义了路径:
// Use path
app.use(express.static(path.join(__dirname, 'public')));
由于某种原因在本地服务器上它显示了所有内容并且没有错误,但是当我将它推送到我的Web服务器(这是一个vps而我使用pm2作为节点进程管理器)时,它会在浏览器中显示错误没有加载管理页面。
请帮忙,这让我发疯了!!!