将ngfilesaver从鲍尔迁移到节点软件包中断

发布于 2025-02-04 15:13:56 字数 3555 浏览 2 评论 0原文

我有一个Angular 1.6项目,该项目确实使用:

node 10.16.0
bower 1.8.14
gulp 3.9.1

使用命令序列构建:

npm install
bower install
gulp

它现在以Bower install逐步划分file> file> file-saver.js# 〜1.201507.2投掷错误:

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

因此,我

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

bower.json.json file(Bower uninstall不起作用)从bower.json.json并安装 anguarlar-file-saver 通过

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

通过通过package.json看起来像这样:

{
  "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"
  }
}

我的src \ app.js包含以下内容:

(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));

我的控制器包含以下内容:

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

因此,现在此命令序列有效:

npm install
bower install
gulp

我在浏览器中遇到此错误

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

但是 我可以通过 npm 而不是 bower 来工作吗?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文