"模块不是一个功能" webpack包中的错误

时间:2017-07-11 07:47:47

标签: javascript angularjs node.js webpack

我有一个简单的java脚本项目,包含两个文件:

 $('#lnkUpload').click(function () {
    var FileToRead = document.getElementById('UserFile');
    if (FileToRead.files.length > 0) {
        var reader = new FileReader();
        // assign function to the OnLoad event of the FileReader  
        // non synchronous event, therefore assign to other method  
        reader.onload = Load_CSVData;
        // call the reader to capture the file  
        reader.readAsText(FileToRead.files.item(0));
    }


});


function Load_CSVData(e) {



    CSVLines = e.target.result.split(/\r\n|\n/);
    $CSVLines = CSVLines.slice(1);
    $.each($CSVLines, function (i, item) {
        if (item === "\n" || item.trim().length <= 2) { return; }
        else {
            var element = item.split(","); // builds an array from comma delimited items  
            var LAccount_id = (element[0] === undefined) ? "" : element[0].trim();
            var LJV = (element[1] === undefined) ? "" : element[1].trim();







        self.userModel.push(new userModel()
            .Account_id(LAccount_id)
            .JV(LJV))
        }
    });

}

version.js定义了一个简单的数据容器:

test_project
   |- version.js
   |- index.js

和index.js定义了一个模块,然后只需要version.js:

module.exports =
    {
        products: [
            {product: 'p1', version: '?'},
            {product: 'p2', version: '?'},
            {product: 'p3', version: '?'},
            {product: 'p4', version: '?'}
        ]
    };

我使用webpack构建此项目时没有错误,但生成的bundle在以下语句中失败

module.exports = module('TestProject', []);
require('./version');

错误

  

未捕获的TypeError:模块不是函数       在对象。 (TestProject.js:103)       在Object.160(TestProject:106)       在 webpack_require (TestProject.js:20)       在15.module.exports.module.deprecate(TestProject.js:66)       在TestProject.js:69

可能是什么问题?

0 个答案:

没有答案