尽管运行了“npm i @types/node --global”,为什么我还是得到“找不到名称‘NgModule’”?

Dav*_*ave 3 npm node-modules typescript angular

尽管遵循此处的建议 - Angular2 代码中的 TypeScript 错误:找不到名称 'module',我仍然收到此错误。我正在使用 Angular 5 和 npm 6.9.0。我正在尝试在这里完成本教程 - https://medium.freecodecamp.org/learn-how-to-create-your-first-angular-app-in-20-min-146201d9b5a7

我在 ./src/app/app.component.ts 文件的顶部有这个

import { Component,trigger,animate,style,transition,keyframes } from '@angular/core';
import { FormsModule }   from '@angular/forms';

@NgModule({
  imports: [
             BrowserModule,
             FormsModule      //<----------make sure you have added this.
           ],
})
Run Code Online (Sandbox Code Playgroud)

但是当我运行我的应用程序时出现错误

localhost:todo-app davea$ ng serve
** NG Live Development Server is listening on localhost:4200, open your browser on http://localhost:4200/ **
Date: 2019-05-17T17:06:29.377Z                                                       
Hash: e9b5158cd1cb6d5685c7
Time: 2561ms
chunk {inline} inline.bundle.js (inline) 3.85 kB [entry] [rendered]
chunk {main} main.bundle.js (main) 2.91 kB [initial] [rendered]
chunk {polyfills} polyfills.bundle.js (polyfills) 577 bytes [initial] [rendered]
chunk {styles} styles.bundle.js (styles) 41.6 kB [initial] [rendered]
chunk {vendor} vendor.bundle.js (vendor) 867 kB [initial] [rendered]

ERROR in src/app/app.component.ts(4,2): error TS2552: Cannot find name 'NgModule'. Did you mean 'module'?
src/app/app.component.ts(6,14): error TS2304: Cannot find name 'BrowserModule'.
Run Code Online (Sandbox Code Playgroud)

我还需要做什么才能让 NgModule 得到认可?

pjl*_*b12 5

此错误 ,Cannot find name 'NgModule'是由于未NgModule从导入@angular/core。将其添加到第一行将解决问题。