Когда я запускаю npm run build
, я получаю эту ошибку:
ERROR in ./src/client.js 7:2
Module parse failed: Unexpected token (7:2)
File was processed with these loaders:
* ./node_modules/jshint-loader/index.js
You may need an additional loader to handle the result of these loaders.
|
| const component = (
> <Router history={browserHistory}>
| {routes}
| </Router>
@ multi babel-polyfill ./src/client.js main[1]
. / Src / client. js (с предупреждением для browserHistory
- не удается разрешить символ 'browserHistory')
import React from 'react';
import ReactDOM from 'react-dom';
import { browserHistory, Router } from 'react-router';
import routes from './routes';
const component = (
<Router history={browserHistory}>
{routes}
</Router>
);
ReactDOM.render(component, document.getElementById('react-view'));
Как я могу это исправить?
Реакция: 16.13.0
webpack: 4.42.0
npm: 6.14.2
webpack-config. js
global.Promise = require('bluebird');
const webpack = require('webpack');
const path = require('path');
const plugins = [
new webpack.DefinePlugin({
'process.env': {
BROWSER: JSON.stringify(true),
NODE_ENV: JSON.stringify(process.env.NODE_ENV || 'development')
}
})
];
module.exports = {
entry: ['babel-polyfill', './src/client.js'],
output: {
filename: 'bundle.js',
path: path.resolve(__dirname, 'dist')
},
module: {
rules: [{
test: /\.js$/, // include .js files
enforce: "pre", // preload the jshint loader
exclude: /node_modules/, // exclude any and all files in the node_modules folder
use: [{
loader: "jshint-loader",
// more options in the optional jshint object
options: { // ⬅ formally jshint property
camelcase: true,
emitErrors: false,
failOnHint: false
}
}]
}]
}
};