1

I have an Angular 1.6 project which did build using:

node 10.16.0
bower 1.8.14
gulp 3.9.1

and with the command sequence:

npm install
bower install
gulp

It now breaks at the bower install step with the file-saver.js#~1.20150507.2 throwing error:

Failed to execute "git ls-remote --tags --heads https://github.com/Teleborder/FileSaver.js.git", exit code of #128

Because of this, I have removed the line

"angular-file-saver": "^1.1.3"

from the bower.json file (bower uninstall did not work for that package) and installed the angular-file-saver package via

npm install angular-file-saver --save-dev

So now the package.json looks like this:

{
  "name": "app",
  "version": "1.0.0",
  "description": "app",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [
    "app"
  ],
  "author": "me",
  "license": "ISC",
  "devDependencies": {
    "angular-file-saver": "^1.1.3",
    "del": "^2.2.2",
    "eslint-config-angular": "^0.5.0",
    "eslint-plugin-angular": "^1.5.0",
    "gulp": "^3.9.1",
    "gulp-angular-filesort": "^1.1.1",
    "gulp-angular-templatecache": "^2.0.0",
    "gulp-autoprefixer": "^3.1.1",
    "gulp-cheerio": "^0.6.2",
    "gulp-clean-css": "^2.2.2",
    "gulp-concat": "^2.6.1",
    "gulp-eslint": "^3.0.1",
    "gulp-filter": "^4.0.0",
    "gulp-flatten": "^0.3.1",
    "gulp-htmlmin": "^3.0.0",
    "gulp-if": "^2.0.2",
    "gulp-inject": "^4.1.0",
    "gulp-ng-annotate": "^2.0.0",
    "gulp-rev": "^7.1.2",
    "gulp-sass": "^3.0.0",
    "gulp-sourcemaps": "^1.9.1",
    "gulp-string-replace": "^0.3.1",
    "gulp-uglify": "^2.0.0",
    "main-bower-files": "^2.13.1",
    "natives": "^1.1.6",
    "require-dir": "^0.3.1",
    "rimraf": "^2.6.2",
    "stream-series": "^0.1.1",
    "uglify-save-license": "^0.4.1",
    "yargs": "^6.5.0"
  },
  "dependencies": {
    "bower": "^1.8.4"
  }
}

My src\app.js contains this:

(function(angular) {
    'use strict';
    angular
        .module('app', [
            'angular-cache',
            'ui.router',
            'ui.router.modal',
            'ui.bootstrap',
            'ui.bootstrap-slider',
            'ui.validate',
            'angular-confirm',
            'ngAnimate',
            'ngFileSaver',
            'angularMoment',
            'pascalprecht.translate',
            'tmh.dynamicLocale']);
}(window.angular));

And my controller contains this:

angular
    .module('app')
    .component('readings', {
        controllerAs: 'vm',
        templateUrl: 'readings/readings.html',
        controller: ReadingsController
    });
function ReadingsController(..., FileSaver, ...) {

So, now this command sequence works:

npm install
bower install
gulp

But I get this error in the browser

Uncaught Error: [$injector:modulerr] Failed to instantiate module app due to:
Error: [$injector:modulerr] Failed to instantiate module ngFileSaver due to:
Error: [$injector:nomod] Module 'ngFileSaver' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument.
http://errors.angularjs.org/1.6.0/$injector/nomod?p0=ngFileSaver

How can I get this package working via npm instead of bower?

Matt W
  • 11,753
  • 25
  • 118
  • 215

0 Answers0