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.

Always extra module errors showing with CSS syntax error

See original GitHub issue

Hi,

I am using mini-css-extract-plugin to create a compiled CSS, but it always showing other module errors with the CSS syntax error.

  • Operating System: macOS Mojave
  • Node Version: v11.14.0
  • NPM Version: 6.9.0
  • webpack Version: 4.31.0
  • mini-css-extract-plugin Version: 0.6.0

Expected Behavior

error  in ./src/_scss/app.scss
      color: $brand-primar
            ^
      Undefined variable: "$brand-primar".
      in /Users/my-name/Desktop/my-project/src/_scss/_sidebar-form.scss (line 15, column 14)

Actual Behavior

error  in ./src/_scss/app.scss

Module build failed (from ../node_modules/mini-css-extract-plugin/dist/loader.js):
ModuleBuildError: Module build failed (from ../node_modules/sass-loader/lib/loader.js):

      color: $brand-primar
            ^
      Undefined variable: "$brand-primar".
      in /Users/my-name/Desktop/my-project/src/_scss/_sidebar-form.scss (line 15, column 14)
    at runLoaders (/Users/my-name/Desktop/my-project/node_modules/webpack/lib/NormalModule.js:301:20)
    at /Users/my-name/Desktop/my-project/node_modules/loader-runner/lib/LoaderRunner.js:367:11
    at /Users/my-name/Desktop/my-project/node_modules/loader-runner/lib/LoaderRunner.js:233:18
    at context.callback (/Users/my-name/Desktop/my-project/node_modules/loader-runner/lib/LoaderRunner.js:111:13)
    at Object.render [as callback] (/Users/my-name/Desktop/my-project/node_modules/sass-loader/lib/loader.js:52:13)
    at Object.done [as callback] (/Users/my-name/Desktop/my-project/node_modules/neo-async/async.js:8077:18)
    at options.error (/Users/my-name/Desktop/my-project/node_modules/node-sass/lib/index.js:294:32)

my setup:

All the dependencies are the latest one.

webpack-config.js

module: {
	rules: [
		{
			test: /\.(s*)css$/,
			exclude: /(node_modules|bower_components)/,
			use: [
				MiniCssExtractPlugin.loader,
				{
					loader: 'css-loader',
					options: {
						url: false,
						sourceMap: true,
						importLoaders: 2,
				  }
				},
				{
					loader: 'postcss-loader',
					options: {
						sourceMap: true,
						plugins: () => [
							require('autoprefixer')
						]
				  }
				},
				{
					loader: 'sass-loader',
					options: {
						sourceMap: true
					}
				},
			]
		}
	]
},

In short, it should only have these few lines to show on the console, but right now all showing the module tracing errors.

Any helps? Thanks!

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
bowencoolcommented, May 20, 2019

Problem solved.

import 'xxx.scss';
1reaction
weilinzungcommented, May 20, 2019

@bowencool, it is not about showing and building with syntax errors. It is why also showing “module error “, like your second screenshot 2&3 line, also under (line 5, column 10) should has all the module tracing errors. Showing syntax error it is fine and it should showing, my problem is the error should be clean without the module errors.

Read more comments on GitHub >

github_iconTop Results From Across the Web

css module not being read: Syntax Error - Stack Overflow
I followed the instuctions to setup css modules, so my webpack.config looks as follows... var path = require('path'); var webpack = ...
Read more >
Misleading error that module does not provide export #32137
You get this: SyntaxError: The requested module './dependency.cjs' does not provide an export named 'name' which is only "true" because ES ...
Read more >
How to Fix the Syntax Error in WordPress - WPBeginner
This article lists some very common mistakes made by beginners when pasting code in WordPress templates. The syntax error is usually caused ...
Read more >
How to Fix the "Parse Error: Syntax Error, Unexpected" in ...
Syntax Error – This error is caused by an error in the PHP structure when a character is missing or added that shouldn't...
Read more >
JavaScript Errors and How to Fix Them - David Walsh Blog
Usually caused by a bug in program logic, causing infinite recursive function calls. How to fix this error: Check recursive functions for bugs ......
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