4

I am new to react and webpack. Everytime i run the program i get this issue which i couldn't resolve. I went through the previous questions and tried their solutions yet still the problem remains the same.

webpack

module.exports = {
    entry: './src/App.js',
    output: {
        path: __dirname,
        filename: 'app.js',
},
    module: {
        loaders: [
            {
                test: /\.jsx?$/,
                exclude: /node_modules/,
                loader: 'babel',
                query: {
                    presets: ['es2015', 'stage-0', 'react']
                },
            },
            {
                test: /\.css$/,
                loader: 'style-loader!css-loader',
            },
        ],
    },
};

App.js

import React from 'react';
import ReactDOM from 'react-dom';

var CommentBox = React.createClass({
    render: function () {
        return (
            <div className="CommentBox">
                Hello, world!I am Comment Box.
            </div>
        );
    }
});

ReactDOM.render(<CommentBox/>, document.getElementById('app'));


package.json 
{
"name": "React-Examples",
"version": "1.0.0",
"description": "",
 "main": "index.js",
 "scripts": {
 "test": "echo \"Error: no test specified\" && exit 1"
},
"author": "Rakesh",
"license": "ISC",
"devDependencies": {
"babel-cli": "^6.14.0",
"babel-core": "^6.14.0",
"babel-loader": "^6.2.5",
"babel-preset-es2015": "^6.14.0",
"babel-preset-react": "^6.5.0",
"webpack": "^1.13.1",
"webpack-dev-server": "^1.14.1"
},
"dependencies": {
"react": "^15.1.0",
"react-dom": "^15.1.0"
 }}

1 Answers1

0

I copied your files and tried install it.

What I encountered is 'npm install' only install dependencies and does not install devDependencies. It happen sometimes...and it might be the case here.

Can you try

npm install --only=dev

Also you are missing one package, babel-preset-stage-0

npm install babel-preset-stage-0 --save-dev

and then try run webpack again?

Doppio
  • 2,018
  • 12
  • 11