css - 使用 sass Node 命令行解析来自 node_modules 的 @use 导入?

标签 css node.js npm sass

我正在尝试使用 material web components 生成的 SASS .

我创建一个新的 Node 元素,如下所示:

mkdir sassplayground

并使用依赖项初始化它:

cd sassplayground
npm i @material/button
npm i @material/theme

如果我们在 test.scss 上运行 sass --watch test.scss:test.css 并包含以下内容:

@use 'sass:map';
@use '@material/button/button' as mdc-button;

我们收到此错误:

Error: Can't find stylesheet to import.
  ╷
2 │ @use '@material/button/button' as mdc-button;
  │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  ╵
  test.scss 2:1  root stylesheet

如果我们通过添加 node_modules 前缀来修复它,如下所示:

@use 'sass:map';
@use 'node_modules/@material/button/button' as mdc-button;

我们收到如下传递依赖错误:

Error: Can't find stylesheet to import.
   ╷
26 │ @use '@material/feature-targeting/feature-targeting';

我们如何解决 node_modules 中的 SASS 依赖关系?

最佳答案

好的,这有效:

sass --watch test.scss:test.css --load-path=node_modules

关于css - 使用 sass Node 命令行解析来自 node_modules 的 @use 导入?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/75869353/

相关文章:

node.js - 如何升级 AWS Beanstalk 上的 NPM?

html - 复选框 :hover + label doesn't work in Chrome 49, 50

css - Tailwind - 灵活划船的 child 不会长高

html - Flexbox 在 Firefox 中看起来完全不同

javascript - 使用 NodeJS 在 JSON 文件中添加新的键值

javascript - npm install(在预安装时优雅地停止进程)

javascript - jQuery - 在父级上添加导航事件类

javascript - 为什么 nodemailer 发送重复的电子邮件?

node.js - 类型错误 : Cannot read property 'apply' of undefined in NodeJS using JEST unit testing

node.js - 我在安装 Angular cli 时遇到问题