question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

cannot use module.less in newest create-react-app

See original GitHub issue

if use [component].module.less, will be cause error as follow

./src/pages/Login/Login.module.less (./node_modules/css-loader/dist/cjs.js??ref–6-oneOf-8-1!./node_modules/postcss-loader/src??postcss!./node_modules/less-loader/dist/cjs.js??ref–6-oneOf-8-3!./src/pages/Login/Login.module.less) ValidationError: Invalid options object. CSS Loader has been initialized using an options object that does not match the API schema. - options has an unknown property ‘localIdentName’. These properties are valid: object { url?, import?, modules?, sourceMap?, importLoaders?, localsConvention?, onlyLocals?, esModule? }

this is a break changes in css-loader. css-loader#2197 default config like this

{
      test: lessModuleRegex,
      use: getLessLoader({
        importLoaders: 2,
        modules: { localIdentName: localIdentName}
      })
    }

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:5
  • Comments:5

github_iconTop GitHub Comments

15reactions
xushengscommented, Mar 12, 2020

It seems to be fixed until V1.0, related issue is #201, and the solution is to downgrade your css-loader to 2.1.1 .

Just tried customize-cra@next, it works now.

1reaction
lireskycommented, Mar 5, 2020

me too

不要在代码中使用 xxx.module.less,使用xxx.less然后引用,或者是参考上面的把custom_cra那一块给改掉就可以了。

Read more comments on GitHub >

github_iconTop Results From Across the Web

Using .less files with React - Stack Overflow
to use less files in a react project created with create-react-app follow these steps: npm run eject; npm i less less-loader ...
Read more >
Use in create-react-app - Ant Design
create -react-app is one of the best React application development tools. We are going to use antd within it and modify the webpack...
Read more >
react-app-rewired - npm
1) Install react-app-rewired · 2) Create a config-overrides.js file in the root directory · 3) 'Flip' the existing calls to react-scripts in npm ......
Read more >
Create React App without Create React App - Bits and Pieces
This article talks about the process of creating react app without using any libraries or frameworks such as “create-react-app” , “NextJS” etc.
Read more >
Using LESS CSS with the latest Create React App-Reactjs
"style" loader turns CSS into JS modules that inject <style> tags. // In production, we use MiniCSSExtractPlugin to extract that CSS // to...
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