我嘗試了很多方法,我搜索了stackoverflow,仍無法解決。 我是一個反應新手。webpack錯誤:您可能需要一個合適的加載程序來處理此文件類型
錯誤:
ERROR in ./public/js/index.jsx
Module parse failed: /home/m/react/r-chat/front/public/js/index.jsx Line 3: Unexpected token
You may need an appropriate loader to handle this file type.
| /*'use strict';*/
|
| import React, { Component, ProTypes } from 'react';
| import { Router, Route, IndexRoute, browserHistory, hashHistory } from 'react-router';
| import Avatar from './components/avatar.jsx';
而且我的WebPack文件:
var webpack = require('webpack');
module.exports = {
entry: './public/js/index.jsx',
output: {
path: './build',
filename: "bundle.js"
},
module: {
loaders: [
{
test: /\.js?$/,
exclude: /node_modules/,
loader: 'babel',
query: {
presets: ['es2015','react']
}
}
]
},
plugins: [
new webpack.NoErrorsPlugin()
]
};
感謝,它的我的疏忽..。 – Jour
@Jour沒問題! Webpack很複雜,很難弄清楚 – erichardson30