How to handle @use imports from node_modules when using the sass node CLI?

Exploring the capabilities of SASS through material web components has been quite intriguing.

To begin, I initiated a new node project in the following manner:

mkdir sassplayground

Then, I installed the necessary dependencies:

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

When attempting to execute sass --watch test.scss:test.css with the content below on test.scss:

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

An error was encountered:

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

To correct this issue, I appended node_modules before the path, resulting in:

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

However, this adjustment led to a transitive dependency error like so:

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

How can we effectively manage SASS dependencies from within node_modules?

Answer №1

This solution seems good:

Use the following command to compile SASS file and watch for changes:
sass --watch test.scss:test.css --load-path=node_modules

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Reset all modifications made by jQuery animations before initializing a fresh animation

Is there a way to reset the changes made to the first div before animating the second div using jQuery animation? $(".order-b").click(function(event){ $(".order-t").animate({top:'30%'}, "slow" ); }); $(".counsel-b").cl ...

<a href="">Download files using Express and Node.JS

When using Apache, it's really easy to configure a file download upon clicking a link. However, I'm having trouble achieving the same functionality with Node.JS. Specifically, I want users to be able to start downloading a file when they click on ...

Breakpoints in VS Code unexpectedly shift to different lines

While I am still working on resolving my other issue related to randomly failing tests using jest and supertest in Node.js, I decided to utilize the VS Code debugger. Initially, I expected it to be straightforward but encountered an unexpected behavior whe ...

Managing the unchangeable nature of Azure Artifacts when working with npm

By utilizing GitVersion mainline mode, we guarantee that each commit will generate a unique version number. However, there are certain situations where it may be necessary to build with the same version number multiple times. One such scenario is when a p ...

What occurs when there are conflicting export names in Meteor?

After researching, I discovered that in Meteor, If your app utilizes the email package (and only if it uses the email package!) then your app can access Email and you can invoke Email.send. While most packages typically have just one export, there a ...

Issue with content not moving downward when the drop-down menu collapses

I'm facing an issue with adjusting the layout of my pages when the main Menu collapses. The links that drop down from the Menu are staying on top of the content, and I want them to move down as well. Unfortunately, since some of my pages are integrate ...

The column width in Bootstrap HTML is too excessive

var parentDiv = document.getElementById("cc"); var statementDiv = document.createElement("div"); var statementName = document.createElement("div"); // var removeIconDiv = document.createElement("div"); // removeIconDiv.className = "col w-25"; // ...

How can I automatically replace environment variables in a .json configuration file upon loading?

As someone who is relatively new to the world of JavaScript, I hope you can bear with me if my question is not quite articulated correctly. I've been tasked with working on a legacy project that relies on loading configuration files from .json files. ...

Don't forget to include the line 'import "reflect-metadata"' at the beginning of your entry point for Jest tests

As I work on developing an application using dependency injection with tsyringe, I came across a case where a service receives the repository as a dependency. Here is an example: import { injectable, inject } from 'tsyringe' import IAuthorsRepos ...

Stepping inside the realm of object-oriented programming, one might wonder how to initialize an object

I wrote this user.js function but I am having trouble creating an instance of it in another file. It seems like the structure is a function that contains a class which has functions within it. user.js 'use strict'; const {Sequelize} = require(&a ...

Preventing errors in a Node.js REST API is essential for maintaining smooth functionality

Hey there! I am currently working on updating the type value in my MongoDB database using a REST API, but I seem to be encountering an issue with an error message stating that it cannot be put (404 not found). Loading app.js app.put('api/types/:_id& ...

Unusual behavior observed in MongoDB connection when attempting to connect to an incorrect host or port combination

For my application, I am utilizing node.js, mongodb, and mongoose version 2.3. The code snippet I am working with is as follows: console.log(config); db = mongoose.connect( config[MONGO_HOST_CONFIG], config[MONGO_ACCOUNTS_DB_CONFIG], config[MONGO_PORT_CO ...

Searching for variables within files using Node.js and constructing an object from the results

Trying to figure out how to streamline this process. Here's the directory structure I'm working with: src/ modules/ clients/ i18n/ en-US.ts tasks/ i18n/ en-US.ts So, ea ...

Is it possible to align the textarea to the right side of its sibling row using justify-content: space-between?

My rows consist of two sides: the right side with text and the left side with buttons, separated by justify-content: space-between; However, for the last row, I want to add a textarea that starts from the right-most side of the buttons. Is there a way to ...

Error message thrown by node express.js indicating that response headers cannot be reset once they have been sent

As a newcomer to both node and express, I may be making a silly mistake. If you want to see the complete source code, please visit: https://github.com/wa1gon/aclogGate/tree/master/server logRouter.get("/loggate/v1/listall", function(req, res) { let ...

Eliminate the preset padding on the left and right sides of the container-fluid in Bootstrap 5

How can I remove the default padding-left and padding-right in a container-fluid using Bootstrap 5? I don't want to use "!important" in my CSS file. I have already tried disabling the default padding with Chrome dev tools but it didn't work. Any ...

Appium with Node.js (wd) becomes unresponsive when unable to locate element

Encountering an issue while using appium with nodejs (wd) and mocha, as there is a loading view in the android app (blackbox testing & I'm not the developer) that needs to be waited for its disappearance. Attempted the following solution: wd.addPromi ...

"Implementation of express-session limited to a single route file cannot be accessed in the app.js file of a

I am encountering an issue with the express-session in node js and express 4. I am setting a session variable inside the routes/index.js file, but it is not available in app.js. However, it is available in another route file users.js routes/index.js var ...

Positioning Images in Bootstrap 4

I'm encountering an issue with Bootstrap 4. The left box isn't aligning properly with the right box. This involves both HTML and CSS. How can I go about resolving this issue? <section> <div class="container"> <div class="row"& ...

in order to retrieve a specific amount of documents from an aggregate group stage, it is necessary to specify the number

Suppose I have a collection of various documents. {_id: mongoId, submittedTo: mongoId, viewCount: 2 } If I wish to retrieve x number of documents with the highest view counts to lowest counts per submittedTo using aggregation in Mongoose/MongoDB, how can ...