Alt JS" _alt2.default不是构造函数"错误

时间:2016-04-19 11:12:09

标签: javascript reactjs webpack

加载应用程序时出现此错误。编译没有任何错误。

  

未捕获的TypeError:_alt2.default不是构造函数

在此文件alt.js

import Alt from 'alt';
const alt = new Alt();
export default alt;

在React和Alt JS应用程序中使用WebPack。

的package.json

{
  "dependencies": {
    "alt": "^0.18.4",
    "alt-container": "^1.0.2",
    "axios": "^0.9.1",
    "lodash": "^4.11.1",
    "marked": "^0.3.5",
    "react": "~0.14.0",
    "react-dom": "~0.14.0"
  },
  "devDependencies": {
    "babel-core": "^5.1.11",
    "babel-loader": "^5.0.0",
    "webpack": "^1.13.0"
  },
  "scripts": {
    "dev": "webpack -wdc --progress",
    "build": "webpack -p"
  }
}

Webpack配置

var path = require('path');

module.exports = {

    entry: [
        './src/app.js'
    ],

    output: {
        path: '../webroot/js/build',
        filename: 'app.js'
    },

    module: {
        loaders: [{
            test: function (filename) {
                if (filename.indexOf('node_modules') !== -1) {
                    return false;
                } else {
                    return /\.js$/.test(filename) !== -1;
                }
            },
            loaders: ['babel-loader']
        }]
    },

    resolve: {
        modulesDirectories: [path.join(__dirname, 'src'), 'node_modules']
    }

};

有什么问题?

编辑#1

我在Webpack配置中使用了externals

externals: /^[a-z\-0-9]+$/,

和错误消息:

  

未捕获的ReferenceError:未定义react

0 个答案:

没有答案