我正在使用 AngularMaterial 和 FlexLayout 在 Angular 中实现示例应用程序。
我已经成功安装并实现了Angular Material Components。我还使用以下命令安装了Flex
npm install @angular/flex-layout --save
但是当我运行我的应用程序时,我在Eclipse Terminal中收到以下警告消息,如下所示
而且我的控制台中也出现以下错误。
package.json
:
{
"name": "angular-material-demo",
"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.0.0",
"@angular/cdk": "^5.0.3",
"@angular/common": "^5.0.0",
"@angular/compiler": "^5.0.0",
"@angular/core": "^5.0.0",
"@angular/flex-layout": "^6.0.0-beta.16",
"@angular/forms": "^5.0.0",
"@angular/http": "^5.0.0",
"@angular/material": "^5.0.3",
"@angular/platform-browser": "^5.0.0",
"@angular/platform-browser-dynamic": "^5.0.0",
"@angular/router": "^5.0.0",
"@types/jwt-decode": "^2.2.1",
"core-js": "^2.4.1",
"font-awesome": "^4.6.3",
"hammerjs": "^2.0.8",
"jwt-decode": "^2.2.0",
"primeng": "^2.0.5",
"rxjs": "^5.5.2",
"web-animations-js": "^2.3.1",
"zone.js": "^0.8.14"
},
"devDependencies": {
"@angular/cli": "1.6.0",
"@angular/compiler-cli": "^5.0.0",
"@angular/language-service": "^5.0.0",
"@types/jasmine": "~2.5.53",
"@types/jasminewd2": "~2.0.2",
"@types/node": "~6.0.60",
"angular-ide": "^0.9.38",
"codelyzer": "^4.0.1",
"jasmine-core": "~2.6.2",
"jasmine-spec-reporter": "~4.1.0",
"karma": "~1.7.0",
"karma-chrome-launcher": "~2.1.1",
"karma-cli": "~1.0.1",
"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": "~3.2.0",
"tslint": "~5.7.0",
"typescript": "~2.4.2"
}
}
我也尝试执行以下步骤。
Edited package.json: Had to change my version for @angular/compiler-cli. In my case I had to bring it back to 5.2.0, as it somehow got to 5.2.10.
Deleted the node_modules directory.
Ran: npm install
Installed: npm install @angular/flex-layout.
但是我又遇到了不同的错误。我还尝试将package.json文件中的flex版本从"@angular/flex-layout": "^6.0.0-beta.16"
更改为"@angular/flex-layout": "^2.0.0-beta.12"
,但是仍然出现这些错误。
有人可以帮我解决这个问题吗??
答案 0 :(得分:3)
您的问题是由npm的旧版本引起的。要检查您的版本,请使用:
npm -v
使用apt install安装了非常老的npm版本(3.5.2)。升级到最新版本:
sudo npm install -g npm
再次检查您的版本,您可能需要打开一个终端以刷新它。截至2018年7月4日,最新npm为6.1.0。清除node_modules文件夹,然后重新下载模块:
rm -rf ./node_modules
npm install
答案 1 :(得分:0)
答案 2 :(得分:0)
我遇到了同样的问题,这是由于package.json中的flex-layout版本所致。 使用命令`
首先卸载模块@ angular / flex-layoutnpm卸载@ angular / flex-layout
然后安装flex-layout@2.0.0-beta.10-4905443
使用命令
的版本npm install @ angular / flex-layout @ 2.0.0-beta.10-4905443-保存
这解决了我的问题。