angular 文件上传 webpack

angular webpack ng-file-upload

我正在尝试让 ng-file-upload 与我的 angularjs 项目一起工作,该项目使用 webpack。我通过 npm 安装了 ng-file-upload 并将其添加到我的主 app.js

var ngFileUpload = require('../../node_modules/ng-file-upload/dist/ng-file-upload.min');
module.exports = angular.module('app', [ngFileUpload])

但我仍然得到:

Uncaught Error: [$injector:modulerr] Failed to instantiate module app due to:
Error: [$injector:modulerr] Failed to instantiate module {} due to:
Error: [ng:areq] Argument 'module' is not a function, got Object

任何人都可以告诉我我做错了什么,因为我试图找到有关此的任何信息但没有成功。

查找 ngFileUpload 正在导出的内容以及模块的名称。现在,您正在 angular 依赖项中注入模块,但您只需要提供 ngFileUpload 模块的名称,而不是 ngFileUpload 本身。这就是您收到此错误的原因。它需要一个模块名称,但得到的是一个对象。