Open gate42srl opened 3 years ago
where the file_saver_1 comes from? I have not found the variable in source code
where the file_saver_1 comes from? I have not found the variable in source code
This is the problem... But I solved simply declaring import {saveAs} from "file-saver"; ( without "as importedSaveAs" ) and obviously changing importedSaveAs(blob, file.url); with saveAs(blob, file.url); This solve my problem luckly.
Hi everyone, I have an Angular 7 webApp in which I use fileSaver to download files from a server. In development mode it works correctly; but when I build in production I have this error in the console: ERROR ReferenceError: file_saver_1 is not defined
I've tried to update the package to the latest version but the problem still persist. My code is: ` import {saveAs as importedSaveAs} from "file-saver"; // other imports @Component({ selector: 'app-agenzie-files', templateUrl: './agenzie-files.component.html', styleUrls: ['./agenzie-files.component.css'] }) export class AgenzieFilesComponent implements OnInit {
// functions and variables definition // Download function: downloadFile(file: any) { this.agencyService.downloadFile(this.user.agency['id'], file.id) .subscribe(blob => { importedSaveAs(blob, file.url); }, error => { this.messageService.add({severity: 'error', summary: 'Attenzione', detail: 'Errore durante il download del file'}); }) }
My package.json is:
"dependencies": { "@agm/core": "^1.0.0", "@angular-material-extensions/link-preview": "^1.0.2", "@angular/animations": "^7.2.15", "@angular/cdk": "^7.3.4", "@angular/common": "7.2.15", "@angular/compiler": "7.2.15", "@angular/core": "7.2.15", "@angular/forms": "7.2.15", "@angular/http": "^7.2.15", "@angular/material": "^7.2.15", "@angular/platform-browser": "7.2.15", "@angular/platform-browser-dynamic": "7.2.15", "@angular/router": "7.2.1", "@ng-bootstrap/ng-bootstrap": "^4.0.1", "angular-mgl-timeline": "^0.3.0", "angular2-csv": "0.2.5", "bower": "^1.8.4", "chart.js": "^2.7.2", "core-js": "^2.5.4", "file-saver": "^2.0.5", "font-awesome": "^4.7.0", "hammerjs": "^2.0.8", "jspdf": "^1.3.5", "ngx-currency": "^2.0.2", "ngx-gallery": "^4.1.2", "node-sass": "^4.13.1", "popper.js": "^1.14.4", "primeicons": "^1.0.0", "primeng": "^8.0.3", "quill": "^1.3.7", "rxjs": "^6.3.3", "rxjs-tslint": "^0.1.8", "tslib": "^1.9.0", "zone.js": "^0.9.1" }, "devDependencies": { "@angular-devkit/build-angular": "^0.10.0", "@angular/cli": "7.3.9", "@angular/compiler-cli": "7.2.9", "@fortawesome/fontawesome-free": "^5.9.0", "@types/file-saver": "^2.0.1", "@types/googlemaps": "^3.30.11", "@types/jasmine": "latest", "@types/jquery": "^3.2.7", "@types/node": "latest", "codelyzer": "latest", "jasmine-core": "latest", "jasmine-spec-reporter": "latest", "karma": "latest", "karma-chrome-launcher": "latest", "karma-cli": "latest", "karma-coverage-istanbul-reporter": "latest", "karma-jasmine": "latest", "karma-jasmine-html-reporter": "latest", "moment": "~2.24.0", "protractor": "latest", "ts-node": "latest", "tslint": "latest", "typescript": "3.2.2", "webpack": "^4.4.1" }`Is there a way to solve this?