我正在使用@ angular / cli(1.0.0-beta.32.3)的最新版本,我正在尝试使用ng2-tag-input。 当我启动ng serve命令时出现此错误:
ERROR in Error encountered resolving symbol values statically. Only initialized variables and constants can be referenced because the value of this variable is needed by the template compiler (position 5:22 in the original .ts file), resolving symbol Ng2DropdownModule in my-project/node_modules/ng2-tag-input/dist/node_modules/ng2-material-dropdown/index.d.ts, resolving symbol TagInputModule in my-project/node_modules/ng2-tag-input/dist/modules/ng2-tag-input.module.d.ts, resolving symbol TagInputModule in my-project/node_modules/ng2-tag-input/dist/modules/ng2-tag-input.module.d.ts
webpack: Failed to compile.
知道如何解决这个问题吗?
这是我的package.json:
{
"name": "my-project",
"version": "0.0.0",
"license": "MIT",
"angular-cli": {},
"scripts": {
"ng": "ng",
"start": "ng serve --proxy-config proxy.conf.json",
"lint": "tslint \"src/**/*.ts\" --project src/tsconfig.json --type-check && tslint \"e2e/**/*.ts\" --project e2e/tsconfig.json --type-check",
"test": "ng test",
"pree2e": "webdriver-manager update --standalone false --gecko false",
"e2e": "protractor",
"build": "ng build --aot"
},
"private": true,
"dependencies": {
"@angular/common": "^2.3.1",
"@angular/compiler": "^2.3.1",
"@angular/core": "^2.3.1",
"@angular/forms": "^2.3.1",
"@angular/http": "^2.3.1",
"@angular/platform-browser": "^2.3.1",
"@angular/platform-browser-dynamic": "^2.3.1",
"@angular/router": "^3.3.1",
"bootstrap-sass": "^3.3.7",
"core-js": "^2.4.1",
"font-awesome": "^4.7.0",
"jquery": "^3.1.1",
"ng2-tag-input": "^0.8.5",
"rxjs": "^5.0.1",
"tinymce": "^4.5.3",
"ts-helpers": "^1.1.1",
"zone.js": "^0.7.2"
},
"devDependencies": {
"@angular/cli": "^1.0.0-beta.32.3",
"@angular/compiler-cli": "^2.3.1",
"@types/jasmine": "2.5.38",
"@types/node": "^6.0.42",
"@types/tinymce": "^4.5.0",
"angular-cli": "1.0.0-beta.26",
"codelyzer": "~2.0.0-beta.1",
"jasmine-core": "2.5.2",
"jasmine-spec-reporter": "2.5.0",
"karma": "1.2.0",
"karma-chrome-launcher": "^2.0.0",
"karma-cli": "^1.0.1",
"karma-jasmine": "^1.0.2",
"karma-remap-istanbul": "^0.2.1",
"protractor": "~4.0.13",
"ts-node": "1.2.1",
"tslint": "^4.3.0",
"typescript": "~2.0.3"
}
}
和我的app.module.ts
import { BrowserModule } from "@angular/platform-browser";
import { NgModule } from "@angular/core";
import { FormsModule } from "@angular/forms";
import { HttpModule } from "@angular/http";
import { TagInputModule } from 'ng2-tag-input';
import { RouterModule } from "@angular/router";
import { ROUTES } from "./app.routes";
import { AppComponent } from "./app.component";
@NgModule({
declarations: [ AppComponent ],
imports: [
BrowserModule,
FormsModule,
HttpModule,
TagInputModule,
RouterModule.forRoot(ROUTES, { useHash: true })
],
providers: [ ],
bootstrap: [AppComponent]
})
export class AppModule {
}
感谢您的帮助!
答案 0 :(得分:3)
正如Galvan建议的那样,使用版本0.8.6的ng2-tag-input节省了我的一天(谢谢!)。
npm i ng2-tag-input@0.8.6 --save
我已提交issue,以便他们可以更新npm registery