当我尝试通过运行npm install --save @angular/material @angular/cdk
将材质库添加到我的角项目时,我遇到了此问题中描述的问题:Error TS2315: Type 'ElementRef' is not generic material angular
所以按照那里的建议,我跑了npm install -g @angular/cli@latest
;现在,所有ng
命令都会产生以下结果:
$ ng
Unknown error: Error: schema with key or id "http://json-schema.org/draft-06/schema" already exists
ng
可以从其他文件夹中运行,所以我想现在项目中的某些内容已被破坏。如何解决这个问题?
搜索此错误消息并没有产生任何有用的信息,项目的json文件(如tsconfig.json)看起来都很好。
的package.json:
{
"name": "some-frontend",
"version": "0.0.0",
"license": "MIT",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build --prod",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"@angular/animations": "6.0.1",
"@angular/cdk": "^6.0.1",
"@angular/common": "6.0.1",
"@angular/compiler": "6.0.1",
"@angular/core": "6.0.1",
"@angular/forms": "6.0.1",
"@angular/http": "6.0.1",
"@angular/material": "^6.0.1",
"@angular/platform-browser": "6.0.1",
"@angular/platform-browser-dynamic": "6.0.1",
"@angular/router": "6.0.1",
"core-js": "^2.4.1",
"npm": "^6.0.1",
"rxjs": "^6.1.0",
"zone.js": "^0.8.26"
},
"devDependencies": {
"@angular/cli": "6.0.1",
"@angular/compiler-cli": "6.0.1",
"@angular/language-service": "6.0.1",
"@types/jasmine": "~2.8.3",
"@types/jasminewd2": "~2.0.2",
"@types/node": "~6.0.60",
"codelyzer": "^4.0.1",
"jasmine-core": "~2.8.0",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~2.0.0",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "^1.2.1",
"karma-jasmine": "~1.1.0",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "~5.1.2",
"ts-node": "~4.1.0",
"tslint": "~5.9.1",
"typescript": "2.7.2"
}
}
以前的package.json文件:
{
"name": "some-frontend",
"version": "0.0.0",
"license": "MIT",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build --prod",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"@angular/animations": "^5.2.0",
"@angular/common": "^5.2.0",
"@angular/compiler": "^5.2.0",
"@angular/core": "^5.2.0",
"@angular/forms": "^5.2.0",
"@angular/http": "^5.2.0",
"@angular/platform-browser": "^5.2.0",
"@angular/platform-browser-dynamic": "^5.2.0",
"@angular/router": "^5.2.0",
"core-js": "^2.4.1",
"rxjs": "^5.5.6",
"zone.js": "^0.8.19"
},
"devDependencies": {
"@angular/cli": "~1.7.4",
"@angular/compiler-cli": "^5.2.0",
"@angular/language-service": "^5.2.0",
"@types/jasmine": "~2.8.3",
"@types/jasminewd2": "~2.0.2",
"@types/node": "~6.0.60",
"codelyzer": "^4.0.1",
"jasmine-core": "~2.8.0",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~2.0.0",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "^1.2.1",
"karma-jasmine": "~1.1.0",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "~5.1.2",
"ts-node": "~4.1.0",
"tslint": "~5.9.1",
"typescript": "~2.5.3"
}
}
答案 0 :(得分:0)
rm -rf /node_modules
,然后通过
再次安装软件包npm install
为我工作。