首页 文章

面对ng2-image-upload的问题 . 编译应用程序时出错

提问于
浏览
0

我一直在使用这个库(https://aberezkin.github.io/ng2-image-upload)一段时间了 . 这是我第一次遇到这个问题 .

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

import { ImageUploadModule } from 'angular2-image-upload';
@NgModule({
....
imports: [
        ...,
        ImageUploadModule.forRoot()
]
...
})

event.component.html

<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

import {FileHolder} from 'angular2-image-upload/src/image-upload/image-upload.component';

1 回答

  • 0

    解决了它将component.ts更改为 -

    import {FileHolder} from 'angular2-image-upload';
    

相关问题