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.

Error triying of compile a single sass file

See original GitHub issue

Bug report

Actual Behavior

I have a template of webpack for my projects maded with react and in the past worked perfectly, but now cant compile a single sass file, i really dont now what i’m dong wrong

Module build failed (from ./node_modules/mini-css-extract-plugin/dist/loader.js):
ReferenceError: document is not defined

Expected Behavior

Compile without errors because the sass file that i try to compile is empty

How Do We Reproduce?

I have a repo with the actual issue, you just should clone and run npm start

Please paste the results of npx webpack-cli info here, and mention other relevant information

Module build failed (from ./node_modules/mini-css-extract-plugin/dist/loader.js):
ReferenceError: document is not defined
    at Object.insertStyleElement (/home/s4malve/code/challenges/devChallenges-recipe-page/node_modules/style-loader/dist/cjs.js!/home/s4malve/code/challenges/devChallenges-recipe-page/node_modules/css-loader/dist/cjs.js!/home/s4malve/code/challenges/devChallenges-recipe-page/node_modules/sass-loader/dist/cjs.js!/home/s4malve/code/challenges/devChallenges-recipe-page/src/components/App/main.scss:322:17)
    at Object.domAPI (/home/s4malve/code/challenges/devChallenges-recipe-page/node_modules/style-loader/dist/cjs.js!/home/s4malve/code/challenges/devChallenges-recipe-page/node_modules/css-loader/dist/cjs.js!/home/s4malve/code/challenges/devChallenges-recipe-page/node_modules/sass-loader/dist/cjs.js!/home/s4malve/code/challenges/devChallenges-recipe-page/src/components/App/main.scss:417:30)
    at addElementStyle (/home/s4malve/code/challenges/devChallenges-recipe-page/node_modules/style-loader/dist/cjs.js!/home/s4malve/code/challenges/devChallenges-recipe-page/node_modules/css-loader/dist/cjs.js!/home/s4malve/code/challenges/devChallenges-recipe-page/node_modules/sass-loader/dist/cjs.js!/home/s4malve/code/challenges/devChallenges-recipe-page/src/components/App/main.scss:213:21)
    at modulesToDom (/home/s4malve/code/challenges/devChallenges-recipe-page/node_modules/style-loader/dist/cjs.js!/home/s4malve/code/challenges/devChallenges-recipe-page/node_modules/css-loader/dist/cjs.js!/home/s4malve/code/challenges/devChallenges-recipe-page/node_modules/sass-loader/dist/cjs.js!/home/s4malve/code/challenges/devChallenges-recipe-page/src/components/App/main.scss:197:21)
    at module.exports (/home/s4malve/code/challenges/devChallenges-recipe-page/node_modules/style-loader/dist/cjs.js!/home/s4malve/code/challenges/devChallenges-recipe-page/node_modules/css-loader/dist/cjs.js!/home/s4malve/code/challenges/devChallenges-recipe-page/node_modules/sass-loader/dist/cjs.js!/home/s4malve/code/challenges/devChallenges-recipe-page/src/components/App/main.scss:234:25)
    at /home/s4malve/code/challenges/devChallenges-recipe-page/node_modules/style-loader/dist/cjs.js!/home/s4malve/code/challenges/devChallenges-recipe-page/node_modules/css-loader/dist/cjs.js!/home/s4malve/code/challenges/devChallenges-recipe-page/node_modules/sass-loader/dist/cjs.js!/home/s4malve/code/challenges/devChallenges-recipe-page/src/components/App/main.scss:575:120
    at /home/s4malve/code/challenges/devChallenges-recipe-page/node_modules/style-loader/dist/cjs.js!/home/s4malve/code/challenges/devChallenges-recipe-page/node_modules/css-loader/dist/cjs.js!/home/s4malve/code/challenges/devChallenges-recipe-page/node_modules/sass-loader/dist/cjs.js!/home/s4malve/code/challenges/devChallenges-recipe-page/src/components/App/main.scss:582:3
    at Object.<anonymous> (/home/s4malve/code/challenges/devChallenges-recipe-page/node_modules/style-loader/dist/cjs.js!/home/s4malve/code/challenges/devChallenges-recipe-page/node_modules/css-loader/dist/cjs.js!/home/s4malve/code/challenges/devChallenges-recipe-page/node_modules/sass-loader/dist/cjs.js!/home/s4malve/code/challenges/devChallenges-recipe-page/src/components/App/main.scss:585:12)
    at Module._compile (/home/s4malve/code/challenges/devChallenges-recipe-page/node_modules/v8-compile-cache/v8-compile-cache.js:192:30)
    at evalModuleCode (/home/s4malve/code/challenges/devChallenges-recipe-page/node_modules/mini-css-extract-plugin/dist/utils.js:46:10)

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:12 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
alexander-akaitcommented, Sep 22, 2021

Again, sass-loader should be after css-loader, please use:

  devMode ? 'style-loader' : MiniCssExtractPlugin.loader,
  'css-loader',
  'sass-loader',

if you want to always extract remove style-loader

0reactions
s4malvecommented, Sep 22, 2021

|

Again, sass-loader should be after css-loader, please use:

  devMode ? 'style-loader' : MiniCssExtractPlugin.loader,
  'css-loader',
  'sass-loader',

if you want to always extract remove style-loader

You are absolutely right, sorry for my stupidity 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to resolve this Sass compiling error? - css - Stack Overflow
the error says that there's no container.scss file or it's unreachable and you're trying to import it, check typos for the file name...
Read more >
Error when trying to compile .scss file/s · Issue #2796 - GitHub
Works for me, looking around at the error in question - "EISDIR: illegal operation on a directory, read", it seems like mix cannot...
Read more >
Ruby Sass Command-Line Interface
It tells Sass to stop compiling immediately when an error is detected, rather than trying to compile other Sass files that may not...
Read more >
Stop using an extension to compile Sass - YouTube
I'm working on a Sass course! - https://beyondcss.dev/?utm_campaign=OlderYouTubeVideos&utm_source=YouTube Links ✓ Stephanie's npm script: ...
Read more >
Error Processing SCSS file - Help - Jekyll Talk
So I'm picking up a legacy jekyll site that uses postcss and tailwind (1.9.6, I think; OLD). When I attempt to build with ......
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