This error comes when in webpack target = node
but i have done target=web
(default)
also i am not loading reactjs externally
this error comes on loading app in browser
what i am doing wrong ?
In Console
File
webpack.config.js
const HtmlWebpackPlugin = require('html-webpack-plugin');
const nodeExternals = require('webpack-node-externals');
const config = {
target: 'web',
externals: [nodeExternals()],
entry: './src/index.js',
output: {
filename: '[name].bundle.js',
path: __dirname + '/build'
},
module: {
rules: [
{
test: /\.js$/,
loader: 'babel-loader',
exclude: /node_modules/
},
{
test: /\.css$/,
use: ExtractTextPlugin.extract({
fallback: "style-loader",
use: "css-loader"
})
},
{
test: /\.(png|svg|jpe?g|gif)$/,
use: [{
loader: 'file-loader',
options: {
name: '[path][name].[ext]'
}
}
]
},
{
test: /\.(woff|woff2|eot|ttf|otf)$/,
use: ['file-loader']
}
]
},
devtool: 'inline-source-map',
plugins: [
new HtmlWebpackPlugin({
title: 'Instarem.com'
})
]
};
module.exports = config;
.babelrc using
babel-preset-env
{
"presets": [
"react",
[
"env",
{
"targets": {
"browsers": ["last 2 versions"]
},
"debug": true,
"modules": "commonjs"
}
]
],
"plugins": [
"transform-object-rest-spread",
"transform-class-properties"
]
}
thanks :)
I found Clue
In facebook's create react app generator bundle it shows
module.exports = __webpack_require__(/*! ./lib/React */ "./node_modules/react/lib/React.js");
but in my case it shows only
module.exports = require("react");