Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.1k views
in Technique[技术] by (71.8m points)

Angular: Module parse failed: Unexpected token (13:15)

I am developing an angular application where I have the following structure:

-App
-----findcourse
-----login
-----mainlayout
-----navbar
-----register

I have defined my routing in app.module.ts and calling it in the html file by using router-outlet. However, when I try to run my code it's throwing an error:

ERROR in ./src/app/app.module.ts 13:15                                                                                  
Module parse failed: Unexpected token (13:15)                                                                           
File was processed with these loaders:                                                                                   
* ./node_modules/@ngtools/webpack/src/index.js                                                                         
You may need an additional loader to handle the result of these loaders.                                                
| import * as i0 from "@angular/core";                                                                                  
| import * as i1 from "@angular/router";                                                                                
> const appRoutes;                                                                                                      
| [                                                                                                                     
|     { path: '/', component: MainlayoutComponent },

Here's my index.js file:

"use strict";
/**
 * @license
 * Copyright Google Inc. All Rights Reserved.
 *
 * Use of this source code is governed by an MIT-style license that can be
 * found in the LICENSE file at https://angular.io/license
 */
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
    for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.NgToolsLoader = exports.default = void 0;
__exportStar(require("./angular_compiler_plugin"), exports);
__exportStar(require("./interfaces"), exports);
var loader_1 = require("./loader");
Object.defineProperty(exports, "default", { enumerable: true, get: function () { return loader_1.ngcLoader; } });
exports.NgToolsLoader = __filename;
question from:https://stackoverflow.com/questions/65860712/angular-module-parse-failed-unexpected-token-1315

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I resolved it by adding this in my index.html file

<app-root>
**<div class="load-container">
  <div class="loader"></div>
</div>**
</app-root>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...