Javascript 带有Sass的Next.js出现在错误时,表示“0”;您可能需要适当的加载程序来处理此文件类型错误;

Javascript 带有Sass的Next.js出现在错误时,表示“0”;您可能需要适当的加载程序来处理此文件类型错误;,javascript,css,sass,next.js,Javascript,Css,Sass,Next.js,我尝试了好几次连接我的next.js和scss,但都没有成功 我想我设置了所有东西,用scss编译我的文件 说这个的错误 /scss/style.scss 1:0 Module parse failed: Unexpected token (1:0) You may need an appropriate loader to handle this file type. > .example { | color: blue; | } 代码如下: next.config.js cons

我尝试了好几次连接我的next.js和scss,但都没有成功

我想我设置了所有东西,用scss编译我的文件

说这个的错误

/scss/style.scss 1:0
Module parse failed: Unexpected token (1:0)
You may need an appropriate loader to handle this file type.
> .example {
|   color: blue;
| }
代码如下:

next.config.js

const withSass = require("@zeit/next-sass");
module.exports = withSass();
import Document, { Head, Main, NextScript } from "next/document";

export default class extends Document {
  render() {
    return (
      <html>
        <Head>

        <link rel="stylesheet" href="/_next/static/style.css" />
        <Head />
        <body>
          <Main />
          <div id="modal" />
          <NextScript />
        </body>
      </html>
    );
  }
}
import "../scss/style.scss";

import axios from "axios";

const Index = props => {
  return (
    <div>
      <div className="example">hello</div>
      <header>
        <Header />
      </header>
      <section>
        <Body stores={props.data} />
      </section>
      <footer>
        <Footer />
      </footer>
    </div>
  );
};
\u document.js

const withSass = require("@zeit/next-sass");
module.exports = withSass();
import Document, { Head, Main, NextScript } from "next/document";

export default class extends Document {
  render() {
    return (
      <html>
        <Head>

        <link rel="stylesheet" href="/_next/static/style.css" />
        <Head />
        <body>
          <Main />
          <div id="modal" />
          <NextScript />
        </body>
      </html>
    );
  }
}
import "../scss/style.scss";

import axios from "axios";

const Index = props => {
  return (
    <div>
      <div className="example">hello</div>
      <header>
        <Header />
      </header>
      <section>
        <Body stores={props.data} />
      </section>
      <footer>
        <Footer />
      </footer>
    </div>
  );
};

尝试添加
导入“./scss/style.scss”
到您的
\u document.js
尝试添加
导入“./scss/style.scss”
到您的
\u document.js

谢谢您的回答。但这并不是这个错误的原因。next.config.js文件应该位于项目目录中(pages文件夹和package.json文件旁边)。我第一次把文件放错地方了谢谢你的回答。但这并不是这个错误的原因。next.config.js文件应该位于项目目录中(pages文件夹和package.json文件旁边)。我第一次把文件放错地方了