【发布时间】:2016-10-18 19:43:25
【问题描述】:
我正在尝试将 ng2-pdf-viewer 添加到我的 angular2 项目中,但我在使用 Angular-CLI 设置它时遇到问题,指南说我应该将映射添加到 systemjs 但 angular-cli 没有'现在不使用 systemjs。 我尝试在 angular-cli.json 中添加 lib 的路径,但它给了我同样的错误。
Uncaught Error: Unexpected value 'PdfViewerComponent' declared by the module 'AppModule'
at http://localhost:3000/vendor.bundle.js:12183:31
at Array.forEach (native)
at CompileMetadataResolver.getNgModuleMetadata (http://localhost:3000/vendor.bundle.js:12170:49)
at RuntimeCompiler.compileComponents (http://localhost:3000/vendor.bundle.js:18476:47)
at RuntimeCompiler._compileModuleAndComponents (http://localhost:3000/vendor.bundle.js:18414:37)
at RuntimeCompiler.compileModuleAsync (http://localhost:3000/vendor.bundle.js:18405:21)
at PlatformRef.bootstrapModuleWithZone (http://localhost:3000/vendor.bundle.js:26818:25)
at PlatformRef.bootstrapModule (http://localhost:3000/vendor.bundle.js:26800:21)
at HTMLDocument.main (http://localhost:3000/main.bundle.js:89232:10)
at ZoneDelegate.invokeTask (http://localhost:3000/polyfills.bundle.js:15379:38)
at Zone.runTask (http://localhost:3000/polyfills.bundle.js:15279:48)
at HTMLDocument.ZoneTask.invoke (http://localhost:3000/polyfills.bundle.js:15447:34)
这是我从组件中得到的错误,该组件使用 pdfjs-dist 并且它不包含任何 ts 文件,并且由于指南说我不能使用 systemjs,因此我需要一些帮助。
angular-cli.json:
{
"project": {
"version": "1.0.0-beta.17",
"name": "ng_pdf_app"
},
"apps": [
{
"root": "src",
"outDir": "dist",
"assets": "assets",
"index": "index.html",
"main": "main.ts",
"test": "test.ts",
"tsconfig": "tsconfig.json",
"prefix": "app",
"mobile": false,
"styles": [
"styles.css",
"../node_modules/bootstrap/dist/css/bootstrap.min.css"
],
"scripts": [
"../node_modules/jquery/dist/jquery.js",
"../node_modules/tether/dist/js/tether.js",
"../node_modules/bootstrap/dist/js/bootstrap.js"
],
"environments": {
"source": "environments/environment.ts",
"dev": "environments/environment.ts",
"prod": "environments/environment.prod.ts"
}
}
],
"addons": [],
"packages": [ {"ng2-pdf-viewer":{ "main": "dist/pdf-viewer.component.min.js", "defaultExtension": "js" }},
{"pdfjs-dist": { "defaultExtension": "js" }}],
"e2e": {
"protractor": {
"config": "./protractor.conf.js"
}
},
"test": {
"karma": {
"config": "./karma.conf.js"
}
},
"defaults": {
"styleExt": "css",
"prefixInterfaces": false
}
}
【问题讨论】:
标签: angular webpack systemjs angular-cli