export 'default' (imported as 'styles') was not found in '../styles.less'

See original GitHub issue

Bug report

Get a warning when i use import styles from "./styles.less" . The warning message like this export 'default' (imported as 'styles') was not found in '../styles.less'

{
      test: /\.(less)(\?.*)?$/,
      oneOf: [
        /* config.module.rule('less').oneOf('css') */
        {
          use: [
            /* config.module.rule('less').oneOf('css').use('extract-css-loader') */
            {
              loader: require.resolve("mini-css-extract-plugin/dist/loader"),
              options: {
                esModule: true,
                modules: {
                  namedExport: true
                },
                publicPath: "./"
              }
            },
            /* config.module.rule('less').oneOf('css').use('css-loader') */
            {
              loader: require.resolve("css-loader"),
              options: {
                esModule: true,
                modules: {
                  namedExport: true,
                  localIdentName: "[local]___[hash:base64:5]"
                },
                importLoaders: 1
              }
            },
            /* config.module.rule('less').oneOf('css').use('postcss-loader') */
            {
              loader: require.resolve("postcss-loader"),
              options: {
                postcssOptions: {
                  ident: "postcss",
                  plugins: [["postcss-preset-env", { stage: 3, autoprefixer: true }]]
                }
              }
          },
            /* config.module.rule('less').oneOf('css').use('less-loader') */
            {
              loader: require.resolve("less-loader"),
              options: {
                lessOptions: {
                  modules: true,
                  modifyVars: undefined,
                  javascriptEnabled: true
                }
              }
            }
          ]
        }
      ]
    }

QQ图片20210202161849

QQ图片20210202161900

Other relevant information: webpack version: 5.18.0 Node.js version: 12.19.0 Operating System: windows 10 Additional tools: visual studio code

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

6reactions
alexander-akaitcommented, Feb 2, 2021

Not related to webpack, please read mini-css-extract-plugin CHANGELOG, mini-css-extract-plugin returns nothing (only named locals if you use CSS modules), so export doesn’t exists, please use import * as locals from './style.css'; console.log(locals.myClass)

4reactions
NexxLuocommented, Feb 5, 2021

Not related to webpack, please read mini-css-extract-plugin CHANGELOG, mini-css-extract-plugin returns nothing (only named locals if you use CSS modules), so export doesn’t exists, please use import * as locals from './style.css'; console.log(locals.myClass)

Thanks . I just set the esModule to false also hidden this error.

Read more comments on GitHub >

github_iconTop Results From Across the Web

WARN export 'default' (imported as 'content') was not found
Hello Friends , today while I was setting up a new React project from scratch without using create-react-app and after doing all the...
Read more >
Ask Question - Stack Overflow
Try import styles from "./styles.module.scss";. It seems you're missing the 'module' in the file name.
Read more >
export 'default' (imported as) was not found in ... - YouTube
Solve this error in your React or React Native project. Professional JavaScript Course: ...
Read more >
Export default was not found Error in JavaScript | bobbyhadz
The "export default was not found" error occurs when we try to import as default from a module that doesn't have a default...
Read more >
rollup-plugin-styles
CSS is available as default export in inject and extract modes, but if CSS Modules are enabled you need to use named css...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found