I am getting the following error in my project:
ModuleBuildError: Module build failed (from ./node_modules/next/dist/build/webpack/loaders/next-babel-loader.js):
TypeError: Cannot read property 'local' of undefined`
Here is my next.config.json
`module.exports = {
webpack: (config, { dev }) => {
config.module.rules.push(
{
test: /\.(less)/,
loader: 'emit-file-loader',
options: {
name: 'dist/[path][name].[ext]'
}
},
{
test: /\.less$/,
use: [
{ loader: 'babel-loader' },
{ loader: 'raw-loader' },
{ loader: 'less-loader', options: { javascriptEnabled: true } }
]
},
{
test: /\.css$/,
exclude: /node_modules/,
loader: [
'css-loader?modules&importLoaders=1&localIdentName=[path]___[name]__[local]___[hash:base64:5]',
'postcss-loader'
]
}
);
return config;
}
};
And my .babelrc file:
{
"plugins": [
["inline-import", { "extensions": [".css"] }],
["import", { "libraryName": "antd" }]
],
"presets": ["next/babel"],
"ignore": []
}
I figured the problem comes up when importing packages: If i import packages in this manner it works: import module from package However, if I import the packages in this manner, I get the error described: import module from package/submodule Why is this happening? I suspect that the problem is with babel-loader but I don't have a clue on how to fix it.
Thanks
.less
files? – iurii.less
files successfully. The problem is when I try to import modules from directories within the package. Could it be a problem with babel-plugin-import? – Dave Kaluimport IntlTelInput from 'react-intl-tel-input';
// this works when I only add this // but it stops working when I import modules like thisimport 'file-loader?name=libphonenumber.js!./libphonenumber.js';
import './main.css';
– Dave Kalu