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.

Bad error message when importing sass without it being installed in dev

See original GitHub issue

The require stack should not be present when importing sass without it installed in dev. This message should be short & sweet.

image

error - ./pages/test.module.scss
To use Next.js' built-in Sass support, you first need to install `sass`.
Run `npm i sass` or `yarn add sass` inside your workspace.

Learn more: https://err.sh/next.js/install-sass
Require stack:
- /Users/joe/Desktop/scratch2/test/node_modules/sass-loader/dist/getDefaultSassImplementation.js
- /Users/joe/Desktop/scratch2/test/node_modules/sass-loader/dist/getSassImplementation.js
- /Users/joe/Desktop/scratch2/test/node_modules/sass-loader/dist/index.js
- /Users/joe/Desktop/scratch2/test/node_modules/sass-loader/dist/cjs.js
- /Users/joe/Desktop/scratch2/test/node_modules/loader-runner/lib/loadLoader.js
- /Users/joe/Desktop/scratch2/test/node_modules/loader-runner/lib/LoaderRunner.js
- /Users/joe/Desktop/scratch2/test/node_modules/webpack/lib/NormalModule.js
- /Users/joe/Desktop/scratch2/test/node_modules/webpack/lib/NormalModuleFactory.js
- /Users/joe/Desktop/scratch2/test/node_modules/webpack/lib/Compiler.js
- /Users/joe/Desktop/scratch2/test/node_modules/webpack/lib/webpack.js
- /Users/joe/Desktop/scratch2/test/node_modules/next/dist/server/hot-reloader.js
- /Users/joe/Desktop/scratch2/test/node_modules/next/dist/server/next-dev-server.js
- /Users/joe/Desktop/scratch2/test/node_modules/next/dist/server/next.js
- /Users/joe/Desktop/scratch2/test/node_modules/next/dist/server/lib/start-server.js
- /Users/joe/Desktop/scratch2/test/node_modules/next/dist/cli/next-dev.js
- /Users/joe/Desktop/scratch2/test/node_modules/next/dist/bin/next
ModuleBuildError: Module build failed (from ./node_modules/sass-loader/dist/cjs.js):
Error: Cannot find module 'node-sass'
Require stack:
- /Users/joe/Desktop/scratch2/test/node_modules/sass-loader/dist/getDefaultSassImplementation.js
- /Users/joe/Desktop/scratch2/test/node_modules/sass-loader/dist/getSassImplementation.js
- /Users/joe/Desktop/scratch2/test/node_modules/sass-loader/dist/index.js
- /Users/joe/Desktop/scratch2/test/node_modules/sass-loader/dist/cjs.js
- /Users/joe/Desktop/scratch2/test/node_modules/loader-runner/lib/loadLoader.js
- /Users/joe/Desktop/scratch2/test/node_modules/loader-runner/lib/LoaderRunner.js
- /Users/joe/Desktop/scratch2/test/node_modules/webpack/lib/NormalModule.js
- /Users/joe/Desktop/scratch2/test/node_modules/webpack/lib/NormalModuleFactory.js
- /Users/joe/Desktop/scratch2/test/node_modules/webpack/lib/Compiler.js
- /Users/joe/Desktop/scratch2/test/node_modules/webpack/lib/webpack.js
- /Users/joe/Desktop/scratch2/test/node_modules/next/dist/server/hot-reloader.js
- /Users/joe/Desktop/scratch2/test/node_modules/next/dist/server/next-dev-server.js
- /Users/joe/Desktop/scratch2/test/node_modules/next/dist/server/next.js
- /Users/joe/Desktop/scratch2/test/node_modules/next/dist/server/lib/start-server.js
- /Users/joe/Desktop/scratch2/test/node_modules/next/dist/cli/next-dev.js
- /Users/joe/Desktop/scratch2/test/node_modules/next/dist/bin/next
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:966:15)
    at Function.Module._load (internal/modules/cjs/loader.js:842:27)
    at Module.require (internal/modules/cjs/loader.js:1026:19)
    at require (internal/modules/cjs/helpers.js:72:18)
    at getDefaultSassImplementation (/Users/joe/Desktop/scratch2/test/node_modules/sass-loader/dist/getDefaultSassImplementation.js:24:10)
    at getSassImplementation (/Users/joe/Desktop/scratch2/test/node_modules/sass-loader/dist/getSassImplementation.js:19:72)
    at Object.loader (/Users/joe/Desktop/scratch2/test/node_modules/sass-loader/dist/index.js:40:61)
    at /Users/joe/Desktop/scratch2/test/node_modules/webpack/lib/NormalModule.js:316:20
    at /Users/joe/Desktop/scratch2/test/node_modules/loader-runner/lib/LoaderRunner.js:367:11
    at /Users/joe/Desktop/scratch2/test/node_modules/loader-runner/lib/LoaderRunner.js:233:18
    at runSyncOrAsync (/Users/joe/Desktop/scratch2/test/node_modules/loader-runner/lib/LoaderRunner.js:143:3)
    at iterateNormalLoaders (/Users/joe/Desktop/scratch2/test/node_modules/loader-runner/lib/LoaderRunner.js:232:2)
    at /Users/joe/Desktop/scratch2/test/node_modules/loader-runner/lib/LoaderRunner.js:205:4
    at /Users/joe/Desktop/scratch2/test/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:85:15
    at processTicksAndRejections (internal/process/task_queues.js:79:11)

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
Timercommented, Jun 9, 2020

There was probably a regression introduced in packages/next/client/dev/error-overlay/format-webpack-messages.js. I’d go there to fix it!

This PR #10797 is suspect.

1reaction
Timercommented, Jun 9, 2020

@moh12594 the error message should be the same, but without the stack trace!

I’d only like to see:

./pages/test.module.scss
To use Next.js' built-in Sass support, you first need to install `sass`.
Run `npm i sass` or `yarn add sass` inside your workspace.

Learn more: https://err.sh/next.js/install-sass

… and that’s it!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error: File to import not found or unreadable: ~bootstrap/scss ...
When Sass is precompiled by its own CLI, it processes @imports by itself, and sometimes thus doesn't understand ~ notation.
Read more >
Troubleshooting Common Errors - Gatsby
If you encounter a webpack error that says Generating SSR bundle failed after installing a plugin and trying to run gatsby develop or...
Read more >
Cannot Find Module Sass: 8 Solutions That You Can Use in ...
Cannot find module sass is an error that occurs if your project has Sass files. Read this article to learn what caused it...
Read more >
Sass Basics
CSS on its own can be fun, but stylesheets are getting larger, ... Once Sass is installed, you can compile your Sass to...
Read more >
How to Fix the Error: "The package could not be installed. The ...
css stylesheet,” gets placed into the theme installation status messaging, right before another message that tells you “Theme installation ...
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