TypeError:对象原型只能是Object或为null:undefined Angular 8 [英] TypeError: Object prototype may only be an Object or null: undefined Angular 8
问题描述
每当我尝试启动我的Web应用程序时,都会出现此Type错误.不知道为什么.
Whenever I try to start up my web app, I get this Type error. Can't figure out why.
更新一些软件包后,我开始获取它.我无法弄清楚是哪个问题,或者是为什么错误指向的代码出错,因为它是我在Angular 8的依赖项中的代码.我不太确定该错误在告诉我什么. 我试图更新所有依赖项.我研究了几乎所有类似的问题解决方案,但它们没有起作用.我不知道是编译器错误,打字稿还是依赖项错误.
I started to get it after I updated some packages. I can't figure out which one was the problem or why the code that the error points to give wrong as it is code in my dependencies for Angular 8. I am not really sure what the error is even telling me. I have tried to update all dependencies. I have looked at almost all the similar question solutions and they have not worked. I can't tell if it is a compiler error, typescript, or a dependency error.
错误
[error] TypeError: Object prototype may only be an Object or null: undefined
at setPrototypeOf (<anonymous>)
at Object.__extends (C:\Users\leahb\Desktop\NH\NH-Senior-Project\node_modules\tslib\tslib.js:65:9)
at C:\Users\leahb\Desktop\NH\NH-Senior-Project\node_modules\@angular\compiler-cli\src\ngtsc\indexer\src\template.js:115:17
tslib.js at line 65
(function (exporter) {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
__extends = function (d, b) {
extendStatics(d, b); *//saying the error is coming from here*
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
PACKAGE.JSON
{
"name": "nh",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e",
"heroku-postbuild": "ng build --prod"
},
"keywords": [
"heroku"
],
"private": true,
"dependencies": {
"@agm/core": "^1.0.0-beta.6",
"@angular-devkit/build-angular": "^0.13.0",
"@angular/animations": "~8.1.2",
"@angular/common": "~8.1.2",
"@angular/core": "~8.1.2",
"@angular/forms": "~8.1.2",
"@angular/platform-browser": "~8.1.2",
"@angular/platform-browser-dynamic": "~8.1.2",
"@angular/router": "~8.1.2",
"@types/googlemaps": "^3.37.0",
"core-js": "^2.5.4",
"font-awesome": "^4.7.0",
"hammerjs": "^2.0.8",
"ngx-gallery": "^5.10.0",
"rxjs": "~6.5.2",
"tslib": "^1.9.0",
"zone.js": "^0.9.1"
},
"devDependencies": {
"@angular/cli": "^7.3.9",
"@angular/compiler": "^7.2.15",
"@angular/compiler-cli": "^8.1.2",
"@angular/language-service": "~8.1.2",
"@types/jasmine": "~2.8.8",
"@types/jasminewd2": "~2.0.3",
"@types/node": "~8.9.4",
"codelyzer": "~4.5.0",
"enhanced-resolve": "^3.3.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.4.5"
},
"engines": {
"node": "10.16.0",
"npm": "6.9.0"
}
}
我希望该应用能够编译,构建和启动.每当我尝试ng服务,ng测试或ng构建时,都会出现此错误.
I expected the app to compile, build, and start up. Whenever I tried ng serve, ng test, or ng build I get this error.
推荐答案
在将CLI全局更新到版本8并通过将我的项目中的angular升级到最新版本来解决该问题之后,我的angular@7
项目也遇到了同样的问题在我的项目目录中运行以下命令:
I had the same problem with my angular@7
project after updating the CLI globally to version 8 and solve it by upgrading angular in my project to the latest version by running this command in my project directory:
ng update @angular/cli @angular/core
您还可以使用allow-dirty
标志绕过回购检查:
You can also use the allow-dirty
flag to bypass the repo check:
ng update @angular/cli @angular/core --allow-dirty
此外,这里提到的升级时还有其他注意事项: https://update.angular.io/#7.0:8.0
Also, there are other things to watch for when upgrading that has mentioned here: https://update.angular.io/#7.0:8.0
这篇关于TypeError:对象原型只能是Object或为null:undefined Angular 8的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!