alferov/angular-file-saver

angular-file-saver browserify

Closed this issue · 3 comments

Hi,

I've been trying to import angular-file-saver via browserify but when I import \dist\angular-file-saver.js, I get the following error during the browserify task on grunt:

Error: Cannot find module './angular-file-saver.service' from 'C:\blah\bower_components\angular-file-saver\dist'

I have also tried to use /src/angular-file-saver.module.js instead which passes the related grunt task but then when running the app I get this error:

Error: saveAs is not supported. Please include saveAs polyfill

I have followed the docs (it's quite simple anyway) to the letter, but no luck.

Any thoughts?

Thanks in advance!

Hey, have you tried to install it using npm?

npm install angular-file-saver -D

UPD: I'm pretty sure it's a bower issue, because some of the dependencies (like Blob.js) imported relatively, and browserify will be looking for Blob.js in /node_modules/Blob.js/ folder in that case.

@evoker I had the same error when trying to import the module with the following code:

require('angular-file-saver/dist/angular-file-saver.js')

The point is you just import (or require) require('angular-file-saver'). Browserify will look up the path angular-file-saver in the NPM-modules and look for a package.json where, the main-field points to the actual js-file.

"main": "src/angular-file-saver-bundle.module.js",

This way, angular-file-saver with browserify works for me.