question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

There's already a module with namespace

See original GitHub issue

The Ember.js application I work on is structured in ‘pods’.

This means that the stylesheet is co-located with the associated template and javascript.

For example

/my-component
     /style.scss
     /component.js
     /template.hbs

When I recently attempted to migrate from @import to @use I get the error

There’s already a module with namespace “style”

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:11 (5 by maintainers)

github_iconTop GitHub Comments

8reactions
jathakcommented, Nov 25, 2019

That error occurs when attempting to @use two modules with the same namespace. The default namespace is the basename of the file passed to the @use rule, so if you had something like:

@use "component-a/style";
@use "component-b/style";

you would get this error because both of those rules use the namespace style. To fix this manually, you can use an as clause to manually specify the namespace for a @use rule. e.g.

@use "component-a/style" as a-style;
@use "component-b/style" as b-style;

To make the migration easier, you can use the Sass migrator, which should automatically add as clauses when necessary (it will also automatically add these namespaces to any variable, mixin, or function references from other files, so you don’t have to do that manually either). If you already used the migrator and the stylesheets it output resulted in this error, then that’s a bug with it, and you should file an issue here.

1reaction
amk221commented, Apr 16, 2020

Thanks @nex3, that helps a little, apart from this use case:

@use 'routes/people/index/index' as people-index;
@use 'routes/people/show/index' as people-show;
@use 'routes/people/create/index' as people-create;
@use 'routes/tags/index/index' as tags-index;
@use 'routes/tags/show/index' as tags-show;
@use 'routes/tags/create/index' as tags-create;

…but I can probably live with that.

In case it’s not clear, the above is required because this doesn’t work for the two reasons mentioned in the comments:

@use 'routes/people/index'   /* "routes/people/index" doesn't automatically pick up "index.scss" inside the index directory */
@use 'routes/people/show';
@use 'routes/people/create';
@use 'routes/tags/index'; 
@use 'routes/tags/show';    /* "show" clashes with the people/show, etc... */
@use 'routes/tags/create';
Read more comments on GitHub >

github_iconTop Results From Across the Web

SassError: There is no module with the namespace "math"
I'm having trouble getting the math SASS library to work in a Vue app. It compiles with Dart Sass, and sass-loader. The Dart...
Read more >
Documentation - Namespaces and Modules - TypeScript
This post outlines the various ways to organize your code using modules and namespaces in TypeScript. We'll also go over some advanced topics...
Read more >
"There is no module with the namespace" error when using ...
"There is no module with the namespace" error when using "<namespace>." syntax to access variables/functions if @use declaration is preceded with variable ...
Read more >
The New SASS Module System: Out with @import, In with @use
In October of 2019 Sass announced their new module system, which primarily addressed the switch from using @import to @use instead.
Read more >
Introducing Sass Modules - CSS-Tricks
Internal Sass features have also moved into the module system, so we have complete control over the global namespace. There are several ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found