Need help. An error occurs during import:
Asked
Active
Viewed 69 times
1 Answers
0
By default, JavaScript assumes imports without a file extension to end in .js
So you're looking for a file at './src/pages/HomeContainer.js' This file doesn't exist. Changing the file extension of HomeContainer to .js will fix the issue or by changing your imports to include the .jsx file extension.
import React from 'react';
import HomeContainer from '.src/pages/HomeContainer.jsx';
If you don't want to add .jsx on your import you could add resolve: { extensions: ['.js', '.jsx'] } to your webpack.config. (From Francesco Orsi's answer https://stackoverflow.com/a/62638083/15067557)
// ...
module: {
loaders: [
{
test: /\.jsx?$/,
include: path.join(__dirname, '/client/src'),
// loader: 'babel',
loader: 'babel-loader',
query: {
presets: ["react", "es2015"],
plugins: ["transform-class-properties"]
}
},
{
test: /\.css$/,
loader: 'style-loader!css-loader'
}
]
},
resolve: {
extensions: ['.js', '.jsx']
}
// ...

Adin
- 1
- 1