I'm trying to follow this tutorial for creating a redux form in my NodeJS application. I put the code in my client side Javascript file and tried to run my application but I got a "require is not defined error". I'm using webpack to compile my Javascript file, which this other post suggested, so I'm not sure how I would go about using the require module on the client side. Is there a step I'm missing in order to be able to use the require module?
These are the lines in my client.js file that are causing the error:
import React, { Component, PropTypes } from 'react'
import { reduxForm } from 'redux-form'
This is what I have in webpack.config.js file:
var webpack = require('webpack');
var path = require('path');
var nodeExternals = require('webpack-node-externals');
var React = require('react');
var redux = require('redux');
var BUILD_DIR = path.resolve(__dirname, 'public');
var APP_DIR = path.resolve(__dirname, 'app');
var config = {
entry: APP_DIR + '/client.js',
output: {
path: BUILD_DIR,
filename: 'bundle.js'
},
target: 'node',
externals: [nodeExternals()],
module: {
loaders: [
{
test: /\.jsx?/,
include: APP_DIR,
loader: 'babel'
}
]
}
};
module.exports = config;