【问题标题】:SASS error import 'variables'. SassError: Can't find stylesheet to importSASS 错误导入“变量”。 SassError:找不到要导入的样式表
【发布时间】:2021-12-17 22:28:34
【问题描述】:

我正面临一个问题。我试图将htmlCSS 文档发送到我的反应项目中。问题是

    ./src/scss/app.scss (./node_modules/css-loader/dist/cjs.js??ref--5-oneOf-6-1!./node_modules/postcss-loader/src??postcss!./node_modules/resolve-url-loader??ref--5-oneOf-6-3!./node_modules/sass-loader/dist/cjs.js??ref--5-oneOf-6-4!./src/scss/app.scss)
    SassError: Can't find stylesheet to import.
      ╷
    1 │ @import 'variables';
      │         ^^^^^^^^^^^
      ╵
      src\scss\components\_header.scss 1:9  @import
      src\scss\components\_all.scss 1:9     @import
      src\scss\app.scss 5:9                 root stylesheet

Original Error Image screenshot

【问题讨论】:

    标签: html css reactjs sass


    【解决方案1】:

    您应该使用完整的路径和文件的扩展名导入它。例如:

    @import './variables.scss';

    如果您使用的是 create-react-app 或 node,您可能需要检查您是否安装了 node-sass。更多信息在这里:https://create-react-app.dev/docs/adding-a-css-modules-stylesheet/

    【讨论】:

    • 感谢您的回复。我已经这样做了,但这没有任何意义。它给出了同样的错误。你能看看我在帖子中添加的图片并写正确的@import吗?
    • node-sass 已安装
    • 试试@import './_variables.scss';
    • 它不起作用
    猜你喜欢
    • 2018-12-10
    • 2022-08-08
    • 2020-11-26
    • 2021-08-11
    • 2022-06-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多