我正在尝试使用ngx-webstorage但我面临一个错误,我没有得到我出错的地方..我正在使用Angular4,错误是
Metadata version mismatch for module E:/mapery-v2/web_page/node_modules/ngx-webstorage/dist/app.d.ts, found version 4, expected 3, resolving symbol AppModule in E:/mapery-v2/web_page/src/app/app.module.ts, resolving symbol AppModule in E:/mapery-v2/web_page/src/app/app.module.ts, resolving symbol AppModule in E:/mapery-v2/web_page/src/app/app.module.ts
任何人都可以帮我解决这个错误。
的package.json:
{
"name": "Web",
"version": "0.0.1",
"private": true,
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build"
},
"dependencies": {
"@angular/animations": "4.2.4",
"@angular/cdk": "^2.0.0-beta.12",
"@angular/common": "4.2.4",
"@angular/compiler": "4.2.4",
"@angular/core": "4.2.4",
"@angular/forms": "4.2.4",
"@angular/http": "4.2.4",
"@angular/material": "^2.0.0-beta.12",
"@angular/platform-browser": "4.2.4",
"@angular/platform-browser-dynamic": "4.2.4",
"@angular/router": "4.2.4",
"hammerjs": "^2.0.8",
"jquery": "^3.2.1",
"ngx-bootstrap": "^2.0.0-beta.11",
"ngx-carousel": "^1.3.5",
"ngx-webstorage": "^2.0.1",
"rxjs": "5.4.2",
},
"devDependencies": {
"@angular/cli": "1.4.9",
"@angular/compiler-cli": "4.2.4",
"@angular/language-service": "4.2.4",
"@types/jasmine": "2.5.53",
"@types/jasminewd2": "2.0.2",
"@types/node": "6.0.60",
"codelyzer": "3.2.0",
"typescript": "2.3.3"
}
}
app.module.ts:
import {Ng2Webstorage} from 'ngx-webstorage';
@NgModule({
declarations: [...],
imports: [
BrowserModule,
Ng2Webstorage,]
答案 0 :(得分:1)
来自您使用的package.json
angular version 4
。
"ngx-webstorage": "^2.0.1"
需要angular5
因此,您必须升级到angular5或将ngx-webstorage
降级到版本,
这是你可以做的,
卸载ngx-webstorage
npm uninstall ngx-webstorage --save
并安装1.8.0
版本
npm install ngx-webstorage@1.8.0 --save
Here is a link where you can find that version mismatch issue