Webpack2 – Es2015 modules not resolved

After spending over two days looking into this, following similar issues raised in this forum, Im posting my problem.

Current Behaviour:
When I run the script ‘start-dev’, webpack2 is unable to resolve es2015 modules.
The error I get is:

ERROR in ./app/index.js
Module not found: Error: Can't resolve 'mod' in '/var/www/homelyfe/hl-app/app'
 @ ./app/index.js 7:11-25

ERROR in ./~/react/react.js
Module not found: Error: Can't resolve './lib/React' in '/var/www/homelyfe/hl-app/node_modules/react'
 @ ./~/react/react.js 3:17-39
 @ ./app/index.js

Webpack2 with babel seems to be unable to locate modules, be the modules in ‘node_modules’ or within ‘app’ folder.

Expected Behaviour:
I should be able to execute the ./app/index.js file & display the console.log the variable being imported from module ./app/mod.js;

Here is the link to the repo:
https://bitbucket.org/kay2dan/webpack2_setup

And here is the webpack.config.js after its built:

{
    entry: {
        app: '/var/www/homelyfe/hl-app/app/index.js'
    },
    output: {
        filename: 'run.build.js',
        path: '/var/www/homelyfe/hl-app/build'
    },
    resolve: {
        alias: {
            assets: '/var/www/homelyfe/hl-app/app/assets',
            components: '/var/www/homelyfe/hl-app/app/components'
        },
        extensions: ['js', 'jsx']
    },
    resolveLoader: {
        modules: ['./node_modules', '/var/www/homelyfe/hl-app/app']
    },
    plugins: [DefinePlugin {
            definitions: [Object]
        },
        HotModuleReplacementPlugin {
            multiStep: true,
            fullBuildTimeout: 200
        },
        HtmlWebpackPlugin {
            options: [Object]
        }
    ],
    module: {
        rules: [{
            test: /\.jsx?$/,
            include: '/var/www/homelyfe/hl-app/app',
            use: [{
                loader: 'babel-loader',
                options: { 
                  presets: [ 'es2015', 'react' ]
                }
            }]
        }]
    },
    devServer: {
        historyApiFallback: true,
        hot: true,
        inline: true,
        stats: 'errors-only'
    }
}

Author: Fantashit

1 thought on “Webpack2 – Es2015 modules not resolved

Comments are closed.