未捕获错误:找不到模块

时间:2017-06-13 12:01:41

标签: reactjs webpack jsx

我不知道为什么找不到模块。我认为webpack.config.js中的 loader 是错误的,但我不知道如何修复它。

未捕获错误:找不到模块" ./ components / Images"     在webpackMissingModule(app.js:3)     在Object._hyphenPattern(app.js:3)     在 webpack_require (bootstrap 8f180ae ......:19)     在module.exports(bootstrap 8f180ae ...:65)     在bootstrap 8f180ae ...:65

webpack.config.js

var webpack = require('webpack')
var path = require('path')

module.exports = {
    entry: {
        app: './src/app.js'
    },
    output: {
        filename: 'build/bundle.js',
        sourceMapFilename: 'build/bundle.map'
    },
    devtool: '#source-map',
    module: {
        loaders: [
            {
                loader: 'babel-loader',
                exclude: /(node_modules)/,
                query: {
                    presets: ['react', 'es2015']
               }
            }
        ]
    }
}

./ SRC /组件/ Images.js

import React, { Component } from 'react'

class Images extends Component {

    render() {
        return (
            <div>
                Images Component
            </div>
       )
    }
}

export default Images

./ SRC / app.js

import React, { Component } from 'react'
import ReactDOM from 'react-dom'
import Images from './components/Images'

class App extends Component {

    render() {
        return (
            <div>
                This is the react App!
                more stuff!!
                <Images />

            </div>
        )
    }
}

ReactDOM.render(<App />, document.getElementById('root'))

0 个答案:

没有答案