首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >面临ng2-image-upload问题。编译应用程序时出错

面临ng2-image-upload问题。编译应用程序时出错
EN

Stack Overflow用户
提问于 2018-03-16 14:47:05
回答 1查看 344关注 0票数 0

我使用这个库(https://aberezkin.github.io/ng2-image-upload)已经有一段时间了。这是我第一次面对这个问题。

代码语言:javascript
复制
ERROR in ./node_modules/angular2-image-upload/src/image-upload/image-upload.component.ts
Module build failed: Error: D:\app\node_modules\angular2-image-upload\src\image-upload\image-upload.component.ts is missing from the TypeScript compilation. Please make sure it is in your tsconfig via the 'files' or
'include' property.
The missing file seems to be part of a third party library. TS files in published libraries are often a sign of a badly packaged library. Please open an issue in the library repository to alert its author and ask them to package the library using the Angular Package Format (https://docs.google.com/document/d/1CZC2rcpxffTDfRDs6p1cfbmKNLA6x5O-NtkJglDaBVs/preview).
at AngularCompilerPlugin.getCompiledFile (D:\app\node_modules@ngtools\webpack\src\angular_compiler_plugin.js:662:23)
at plugin.done.then (D:\app\node_modules@ngtools\webpack\src\loader.js:467:39)
at 
at process._tickCallback (internal/process/next_tick.js:188:7)
@ ./src/app/components/event.component.ts 22:31-103
@ ./src/app/app.module.ts
@ ./src/main.ts
@ multi webpack-dev-server/client?http://0.0.0.0:0 ./src/main.ts

webpack: Failed to compile.

如何解决?

app.module.ts

代码语言:javascript
复制
import { ImageUploadModule } from 'angular2-image-upload';
@NgModule({
....
imports: [
        ...,
        ImageUploadModule.forRoot()
]
...
})

event.component.html

代码语言:javascript
复制
<image-upload [max]="10" [uploadedFiles]="home.images"
                                                                  (removed)="onImageRemoved($event)"
                                                                  [extensions]="['jpeg','jpg','png']"
                                                                  (beforeUpload)="imageCheck($event)"
                                                                  (uploadFinished)="onImageUploadFinished($event)"
                                                                    [maxFileSize]="2097152"
                                                                    [fileTooLargeMessage]="'An image was too large and was not uploaded. The maximum file size is 2 Mb.'">
                                                    </image-upload>

event.component.ts

代码语言:javascript
复制
import {FileHolder} from 'angular2-image-upload/src/image-upload/image-upload.component';
EN

回答 1

Stack Overflow用户

发布于 2018-03-16 15:03:52

解决了它把component.ts改成-

代码语言:javascript
复制
import {FileHolder} from 'angular2-image-upload';
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/49314718

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档