我以前也遇到过这种情况,但为了我的爱,我不记得我是如何绕过它的。本质上,我正在编译产品中的构建以导出到我的Cpanel ( testing ),以共享测试应用程序。
但是,我在服务器路径上没有任何信息。
因为它是一个测试服务器,所以我必须使用公共html ->文件夹->应用程序
我得到的唯一控制台响应是资源加载失败,所以我认为如何构建应用程序是一个问题
我的构建命令:npm run build -- --prod --baseHref=/booking/thorpesfarm
我得到的唯一错误/警告是:
Error
DeprecationWarning: Use of deprecated folder mapping "./" in the "exports" - node_modules/tslib/package.json.Warning:
src/main.ts depends on 'hammerjs'. CommonJS or AMD dependencies can cause optimization bailouts.
For more info see: https://angular.io/guide/build#configuring-commonjs-dependencies我的angular.json警告:
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
Unable to load schema from:thorpesfarm/node_modules/@angular/cli/lib/config/schema.json': ENOENT: no such file or directory, open我相信没有任何东西会影响整个构建的运行。申请服务对当地没有问题的罚款。我的注射过程如下:
-Clear区
-Run构建命令
-Zip域文件夹
-Upload到Cpanel
-Unpack
-Visit服务器路径
注释:以前的版本在WebServer上运行得很好,有节点支持,我删除了我用用于构建的命令所做的一个注释(所以我相当肯定问题就在这里),我有接近0的经验/知识,当涉及到角度生产时。有人知道会发生什么事吗?
我的Index.html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Thorpes Farm</title>
<base href="./">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/x-icon" href="favicon.ico">
<!-- Compiled and minified Materialize CSS -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/css/materialize.min.css">
<!-- Compiled and minified Materialize JavaScript -->
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@9"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js"></script><!-- Google Material Icons --><link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet" />
<link href="https://fonts.googleapis.com/css?family=Roboto:300,400,500&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Titillium+Web" rel="stylesheet">
</head>
<body style="overflow-x:hidden;" class="mat-typography igx-typography">
<app-root></app-root>
</body>
</html>发布于 2022-02-04 06:36:39
如OP所示
通过在他的href上更改: Base href,解决了这个问题。
不正确
<base href="/booking/thorpesfarm">
校正
<base href="/booking/thorpesfarm/">
在OP的例子中,编译器期望在forwardSlash /的末尾有一个href。
这意味着基于href的Index.html将如下所示:
<base href="./">
https://stackoverflow.com/questions/70751630
复制相似问题