Module not found cannot solve
I tried to look at some of the answers to this similar question, but none of the solutions I tried from there worked.
I am trying to create a function in an external javascript file and I would like to use this 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 I try 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 tried changing the file path to relative but didn't try, but I also tried adding multiple entry points to the webpack config file but still no luck.
+3
source to share