1

My angular 7 project was working perfectly until this afternoon. When I did 'ng serve' I got these errors: node_modules/@angular/common/http/src/client.d.ts(2514,30): error TS2304: Cannot find name 'ArrayBuffer'. node_modules/@angular/common/http/src/client.d.ts(2580,30): error TS2304: Cannot find name 'Object'. node_modules/@angular/common/http/src/client.d.ts(2621,33): error TS2304: Cannot find name 'ArrayBuffer'. and so it goes on till the end of all node_modules. I tried deleting the node_module folder and then 'npm install". Still it didn't work.

This is my package.json file

{
  "name": "cotrajectplanner2",
  "version": "0.0.0",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "~7.2.0",
    "@angular/common": "~7.2.0",
    "@angular/compiler": "~7.2.0",
    "@angular/core": "~7.2.0",
    "@angular/forms": "~7.2.0",
    "@angular/platform-browser": "~7.2.0",
    "@angular/platform-browser-dynamic": "~7.2.0",
    "@angular/router": "~7.2.0",
    "angular-chart.js": "^1.1.1",
    "bootstrap": "^4.4.1",
    "chart.js": "^2.9.3",
    "core-js": "^2.5.4",
    "jquery": "^3.4.1",
    "jqwidgets-ng": "^8.3.2",
    "popper.js": "^1.16.0",
    "router": "^1.3.3",
    "rxjs": "~6.3.3",
    "tslib": "^1.9.0",
    "zone.js": "~0.8.26"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "~0.13.0",
    "@angular/cli": "~7.3.3",
    "@angular/compiler-cli": "~7.2.0",
    "@angular/language-service": "~7.2.0",
    "@types/jasmine": "~2.8.8",
    "@types/jasminewd2": "~2.0.3",
    "@types/node": "~8.9.4",
    "codelyzer": "~4.5.0",
    "jasmine-core": "~2.99.1",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "~4.0.0",
    "karma-chrome-launcher": "~2.2.0",
    "karma-coverage-istanbul-reporter": "~2.0.1",
    "karma-jasmine": "~1.1.2",
    "karma-jasmine-html-reporter": "^0.2.2",
    "protractor": "~5.4.0",
    "ts-node": "~7.0.0",
    "tslint": "~5.11.0",
    "typescript": "3.1.1"
  }
}

Thanks in advance

Sincerely Sarah

Edit: added app.module.ts

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';

import { AppComponent } from './app.component';
import { LoginComponent } from './general/login/login.component';
import { RouterModule } from '@angular/router';
import { AppRoutingModule } from './app-routing.module';
import { HomeStudentComponent } from './student/home-student/home-student.component';
import { HomeTeacherComponent } from './teacher/home-teacher/home-

teacher.component';
import { StudentInfoComponent } from './student/student-info/student-info.component';
import { StudentStudyProgressComponent } from './student/student-study-progress/student-study-progress.component';
import { StudentOnMyWayToComponent } from './student/student-on-my-way-to/student-on-my-way-to.component';
import { OverviewTrajectoriesComponent } from './teacher/overview-trajectories/overview-trajectories.component';
import { OverviewCoursesComponent } from './teacher/overview-courses/overview-courses.component';
import { OverviewStudentsComponent } from './teacher/overview-students/overview-students.component';
import {HttpClientModule} from '@angular/common/http';
import { FooterComponent } from './general/footer/footer.component';
import { HeaderComponent } from './general/header/header.component';

@NgModule({
  declarations: [
    AppComponent,
    LoginComponent,
    HomeStudentComponent,
    HomeTeacherComponent,
    StudentInfoComponent,
    StudentStudyProgressComponent,
    StudentOnMyWayToComponent,
    OverviewTrajectoriesComponent,
    OverviewCoursesComponent,
    OverviewStudentsComponent,
    FooterComponent,
    HeaderComponent
  ],
  imports: [
    BrowserModule,
    RouterModule,
    AppRoutingModule,
    HttpClientModule
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }
Sarah De Cock
  • 87
  • 1
  • 2
  • 10

2 Answers2

0

Execute this cmd - npm init

for more details click on this link -npm install doesn't create node_modules directory

Bheem Singh
  • 607
  • 7
  • 13
0

I would suggest doing the following

  1. Delete the node_modules on your file system
  2. Make the directory node_modules on your file system
  3. npm cache clean
  4. npm i

Proposed solution:

import {HttpClient} from '@angular/common/http'

remove

import {HttpClientModule} from '@angular/common/http';
Maartenw
  • 595
  • 1
  • 5
  • 19
  • Thanks for your answer. Unfortunately, this did not help in my case.. I still get the same errors – Sarah De Cock Nov 29 '19 at 14:48
  • Is it useful if I just create a new project because I'm just in the beginning phase? I just don't want it to happen again – Sarah De Cock Nov 29 '19 at 14:51
  • Hey @SarahDeCock, could you try importing the following: `import {HttpClient} from '@angular/common/http';` – Maartenw Nov 29 '19 at 15:12
  • Really thank you! After adding what you suggested in the app.module.ts it worked! I still don't understand why one line code could cause such errros and that that import is not used in the module.ts . But thank you very much! – Sarah De Cock Nov 29 '19 at 16:36