Reputation: 4190
When I tried adding the Material library to my angular project by running npm install --save @angular/material @angular/cdk
, I ran into the problems described in this question: Error TS2315: Type 'ElementRef' is not generic material angular
So following the advice there, I ran npm install -g @angular/cli@latest
; now, all ng
commands yield the following:
$ ng
Unknown error: Error: schema with key or id "http://json-schema.org/draft-06/schema" already exists
ng
works from other folders, so I guess something is now broken within the project. How can this be fixed?
Searching for this error message didn't yield anything useful and the project's json files (like tsconfig.json) all look fine.
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"
}
}
Previous package.json file:
{
"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"
}
}
Upvotes: 0
Views: 4883
Reputation: 7058
rm -rf /node_modules
and after that installing the packages again by
npm install
worked for me.
Upvotes: 1
Reputation: 4190
It seems that this was caused by packages which haven't been installed completely/wrong. Running
npm install --save
caused npm to complain about broken files; after removing those, the installation completed successfully.
Then however ng complained about the file angular.json
being missing; this can be fixed by migrating properly, as described in a related question:
ng update @angular/cli --migrate-only --from=1.7.4
Upvotes: 2