为此,我已经用力敲了将近10个小时,但无法解决。
我创建了一个新的Angular项目,当我运行该项目时运行良好,但是一旦我安装并尝试导入材质模块,编译器就会开始抛出错误
错误TS2307:找不到模块'@ angular / core'。
当我从应用模块中删除导入语句时,该错误消失了
我尝试重新安装节点@ angular / cli和所有软件包,但是不起作用。
如果有帮助,package.json
拥有
{
"name": "firebase",
"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": "^8.2.8",
"@angular/common": "~8.2.8",
"@angular/compiler": "~8.2.8",
"@angular/core": "~8.2.8",
"@angular/flex-layout": "^8.0.0-beta.27",
"@angular/forms": "~8.2.8",
"@angular/material": "^8.2.1",
"@angular/platform-browser": "~8.2.8",
"@angular/platform-browser-dynamic": "~8.2.8",
"@angular/router": "~8.2.8",
"hammerjs": "^2.0.8",
"rxjs": "~6.4.0",
"tslib": "^1.10.0",
"zone.js": "~0.9.1"
},
"devDependencies": {
"@angular-devkit/build-angular": "~0.803.6",
"@angular/cli": "~8.3.6",
"@angular/compiler-cli": "~8.2.8",
"@angular/language-service": "~8.2.8",
"@types/node": "~8.9.4",
"@types/jasmine": "~3.3.8",
"@types/jasminewd2": "~2.0.3",
"codelyzer": "^5.0.0",
"jasmine-core": "~3.4.0",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~4.1.0",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "~2.0.1",
"karma-jasmine": "~2.0.1",
"karma-jasmine-html-reporter": "^1.4.0",
"protractor": "~5.4.0",
"ts-node": "~7.0.0",
"tslint": "~5.15.0",
"typescript": "~3.5.3"
}
}
很乐意提供所需的任何信息。
答案 0 :(得分:1)
我记得由角度cdk引起的类似情况,您可以尝试以下命令吗?
npm install --save @angular/material @angular/cdk
rm -rf node_modules
npm install