【问题标题】:TypeError: The "original" argument must be of type Function - SASSTypeError:“原始”参数必须是函数类型 - SASS
【发布时间】:2023-04-05 00:20:01
【问题描述】:

我正在尝试使用 dart-sass 模块在我的 React 项目中使用 Typescript 编译一些 SCSS。我安装了模块,导入了它,并得到标题中的错误。会是什么呢?我尝试过的某些类型的导入:

import { renderSync } from 'sass';
import sass from 'sass';
const sass = require('sass');

一切都会抛出以下错误:

TypeError:“原始”参数的类型必须是 Function - SASS

【问题讨论】:

    标签: sass dart-sass


    【解决方案1】:

    尝试按照以下步骤操作,我认为它会解决您的问题:

    将 node-sass 添加到您的项目中

    $ npm i node-sass --save-dev
    

    在你的 Gruntfile 中包含 node-sass

    const sass = require('node-sass');
    

    在您的 sass 选项中,更改以下行

    来自

    implementation: 'sass-dist'
    

    implementation: sass
    

    【讨论】:

    • 我的项目中没有 Gruntfile,我也不需要。我正在使用 react 自带的 webpack。
    • 问题是,“node-sass”不支持苹果M1 CPU架构。
    • 我最终还是没有采用这个解决方案,但感谢你们两位的提醒。
    猜你喜欢
    • 2020-06-20
    • 2020-10-31
    • 1970-01-01
    • 2021-06-18
    • 2020-08-29
    • 2019-10-01
    • 1970-01-01
    • 2022-01-10
    • 2019-01-24
    相关资源
    最近更新 更多