I have been following the react setup instructions on codecademy:
When I type in “npm run build” into the terminal I get this error:
I can’t seem to figure out how to get it to work.
Here is the link to my code on my github: https://github.com/throwkill999/react_demo
Advertisement
Answer
The error tells you that output.build
is not a valid option. You probably meant to use output.path
. There are other problems with how you concatenate __dirname
in some places, because you need a leading /
for them. But it’s better to use path.resolve
for that.
Your config would look like this:
var path = require('path'); var HTMLWebpackPlugin = require('html-webpack-plugin'); var HTMLWebpackPluginConfig = new HTMLWebpackPlugin({ template: path.resolve(__dirname, 'app/index.html'), filename: 'index.html', inject: 'body' }); module.exports = { entry: path.resolve(__dirname, 'app/index.js'), module: { loaders: [ { test: /.js$/, exclude: /node_modules/, loader: 'babel-loader' } ] }, output: { filename: 'transformed.js', path: path.resolve(__dirname, 'build') }, plugins: [HTMLWebpackPluginConfig] };
Also in ./app/index.js
you have a typo, it should be ./components/Apps
(you forgot the s
).