Next.js: Error: Cannot find module 'node-sass'

Created on 10 Mar 2020  路  2Comments  路  Source: vercel/next.js

Bug report

Describe the bug

Using any example from the Next.js 9.3 blog article for Scss support does not work (global scss or scss modules: Error: Cannot find module 'node-sass'


details:

./components/Button.module.scss (./node_modules/css-loader/dist/cjs.js??ref--5-oneOf-3-1!./node_modules/postcss-loader/src??__nextjs_postcss!./node_modules/resolve-url-loader??ref--5-oneOf-3-3!./node_modules/sass-loader/dist/cjs.js??ref--5-oneOf-3-4!./components/Button.module.scss)
Error: Cannot find module 'node-sass'
Require stack:
- /Users/pierre/dev/next-sass/node_modules/sass-loader/dist/getDefaultSassImplementation.js
- /Users/pierre/dev/next-sass/node_modules/sass-loader/dist/getSassImplementation.js
- /Users/pierre/dev/next-sass/node_modules/sass-loader/dist/index.js
- /Users/pierre/dev/next-sass/node_modules/sass-loader/dist/cjs.js
- /Users/pierre/dev/next-sass/node_modules/loader-runner/lib/loadLoader.js
- /Users/pierre/dev/next-sass/node_modules/loader-runner/lib/LoaderRunner.js
- /Users/pierre/dev/next-sass/node_modules/webpack/lib/NormalModule.js
- /Users/pierre/dev/next-sass/node_modules/webpack/lib/NormalModuleFactory.js
- /Users/pierre/dev/next-sass/node_modules/webpack/lib/Compiler.js
- /Users/pierre/dev/next-sass/node_modules/webpack/lib/webpack.js
- /Users/pierre/dev/next-sass/node_modules/next/dist/server/hot-reloader.js
- /Users/pierre/dev/next-sass/node_modules/next/dist/server/next-dev-server.js
- /Users/pierre/dev/next-sass/node_modules/next/dist/server/next.js
- /Users/pierre/dev/next-sass/node_modules/next/dist/server/lib/start-server.js
- /Users/pierre/dev/next-sass/node_modules/next/dist/cli/next-dev.js
- /Users/pierre/dev/next-sass/node_modules/next/dist/bin/next

To Reproduce

  1. minimal Next.js setup
  2. Follow the instructions to add Global Sass or Sass module https://nextjs.org/blog/next-9-3#built-in-sass-support-for-global-stylesheets
  3. npm run dev
  4. go to the corresponding page

Expected behavior

A clear and concise description of what you expected to happen.

Screenshots

Screen Shot 2020-03-10 at 16 22 53

Screen Shot 2020-03-10 at 16 34 21

System information

  • OS: macOS Catalina
  • Browser (if applies) n/a
  • Version of Next.js: 9.3.0
  • Node.js: 12 & 13 (did not test with others)

Additional context

n/a

Most helpful comment

Ok, so I fooled myself: the doc explains well to npm install sass manually, but it was not mentioned the blog article. Maybe a clearer warning would be welcome 馃憤

All 2 comments

Ok, so I fooled myself: the doc explains well to npm install sass manually, but it was not mentioned the blog article. Maybe a clearer warning would be welcome 馃憤

the docs:

Next.js has built in sass support

the reality:

Error: Cannot find module 'sass'

Was this page helpful?
0 / 5 - 0 ratings