Module not found can't resolve

Viewed 62983

I've tried looking at some of the answers to this similar question but none of the solutions I have attempted from there have worked.

I'm trying to create a function in an external javascript file and I would like to use that function in my main javascript file.

File Structure

webpack.config.js
app
-- index.js
-- test.js

webpack.config.js

module.exports = {
    devtool: "cheap-module-source-map",
    entry: "./app/index.js",
    output: {
        filename: "public/bundle.js"
    },
    module: {
        loaders: [
            {
                test: /\.jsx?$/,
                exclude: /(node_modules|bower_components)/,
                loader: 'babel-loader',
                query:
                {
                    presets: ['es2015']
                }
            }
        ]
    }
};

test.js

export default function test(message) {
    console.log(message);
}

index.js

"use strict"

import test from './app/test.js';

When attempting to run the webpack command I get the error:

ERROR in ./app/index.js

Module not found: Error: Can't resolve './app/test.js'

I've tried changing the file path to a relative one with no luck and I've also tried adding multiple entry points in the webpack config file but still no luck.

1 Answers
Related