Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ng Serve returns "Object prototype may only be an Object or null: undefined TypeError: Object prototype may only be an Object or null: undefined"

I am running a MEAN Stack site and in particular I'm using Angular for my frontend. I recently updated my package.json file to update @angular/compiler-cli from "^7.1.4" to "^8.2.4". Here is the rest of my package.json file:

{
  "name": "monster-playbook",
  "version": "0.0.0",
  "scripts": {
    "ng": "ng",
    "start": "node server.js",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e",
    "postinstall": "ng build --output-path dist"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "~7.1.0",
    "@angular/cli": "^7.1.4",
    "@angular/common": "~7.1.0",
    "@angular/compiler": "~7.1.0",
    "@angular/compiler-cli": "^8.2.4",
    "@angular/core": "~7.1.0",
    "@angular/forms": "~7.1.0",
    "@angular/http": "^7.1.1",
    "@angular/platform-browser": "~7.1.0",
    "@angular/platform-browser-dynamic": "~7.1.0",
    "@angular/router": "~7.1.0",
    "@ng-bootstrap/ng-bootstrap": "^4.0.3",
    "body-parser": "^1.18.3",
    "bootstrap": "^4.0.0-beta",
    "core-js": "^2.5.4",
    "express": "^4.16.4",
    "font-awesome": "^4.7.0",
    "mongodb": "^3.1.13",
    "rxjs": "~6.3.3",
    "tslib": "^1.9.0",
    "zone.js": "~0.8.26"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "^0.12.4",
    "@angular/language-service": "~7.1.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.3.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.5.3"
  }
}

Since then, I've been running into errors whenever I try to run ng serve. Specifically, the error I'm running into currently reads:

Object prototype may only be an Object or null: undefined
TypeError: Object prototype may only be an Object or null: undefined
    at setPrototypeOf (<anonymous>)
    at Object.__extends (C:\Users\Ben\Documents\Coding\Monster-Playbook\node_modules\tslib\tslib.js:64:9)
    at C:\Users\Ben\Documents\Coding\Monster-Playbook\node_modules\@angular\compiler-cli\src\ngtsc\indexer\src\template.js:115:17
    at C:\Users\Ben\Documents\Coding\Monster-Playbook\node_modules\@angular\compiler-cli\src\ngtsc\indexer\src\template.js:314:6
    at C:\Users\Ben\Documents\Coding\Monster-Playbook\node_modules\@angular\compiler-cli\src\ngtsc\indexer\src\template.js:3:17
    at Object.<anonymous> (C:\Users\Ben\Documents\Coding\Monster-Playbook\node_modules\@angular\compiler-cli\src\ngtsc\indexer\src\template.js:9:3)
    at Module._compile (internal/modules/cjs/loader.js:778:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
    at Function.Module._load (internal/modules/cjs/loader.js:585:3)
    at Module.require (internal/modules/cjs/loader.js:692:17)
    at require (internal/modules/cjs/helpers.js:25:18)
    at C:\Users\Ben\Documents\Coding\Monster-Playbook\node_modules\@angular\compiler-cli\src\ngtsc\indexer\src\transform.js:20:22
    at C:\Users\Ben\Documents\Coding\Monster-Playbook\node_modules\@angular\compiler-cli\src\ngtsc\indexer\src\transform.js:10:17
    at Object.<anonymous> (C:\Users\Ben\Documents\Coding\Monster-Playbook\node_modules\@angular\compiler-cli\src\ngtsc\indexer\src\transform.js:16:3)
    at Module._compile (internal/modules/cjs/loader.js:778:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
    at Function.Module._load (internal/modules/cjs/loader.js:585:3)
    at Module.require (internal/modules/cjs/loader.js:692:17)

I've already attempted to revert the change and re-run npm install, but this hasn't helped. I've also

like image 415
B. Allred Avatar asked Sep 05 '19 20:09

B. Allred


2 Answers

I upgraded to Angular 8 and needed to update typescript to 3.4 to get past this error.

like image 139
Chip Avatar answered Oct 26 '22 00:10

Chip


In my case where I was updating my angular app from 6.1 to 8.2 - npm install @angular/[email protected] fixed this issue.

like image 36
j_akshay Avatar answered Oct 26 '22 02:10

j_akshay