加载页面时,得到错误,因为找不到要求,在我使用templateUrl的行中,但是系统非常稳定,不知道错误发生在哪里......
import {Component, OnInit} from '@angular/core';
import {Http} from '@angular/http';
import {Title} from '@angular/platform-browser';
@Component({
selector: 'app-login',
templateUrl: './login.component.html'
})
export class LoginComponent implements OnInit {
}
答案 0 :(得分:3)
你正在使用Typescript,Typescript编译器类型 - 检查你编译的所有内容,看看它是否可以帮助你弹出一些错误。
你得到的错误是Typescript让你知道它不能识别require
函数。
应用程序运行正常,因为它最终仍然可以在运行时使用,因此您获得的错误仅仅是来自Typescript编译器的“警告”。
要解决此问题,您必须“教授”关于require
等功能的Typescript,
你可以通过运行:
npm install --save @types/node
(您可以选择将以下内容添加到tsconfig.json
,以便从node_modules/@types
加载类型:
"typeRoots": [
"./node_modules/@types"
],
)