Skip to content

Unable to resolve module error and reproduction of issue #109

Closed
@jsonnull

Description

@jsonnull

I've run into a bunch of issues attempting to use @import and url() when adding CSS modules to a current project and using less-loader.

It looks like a lot of people have this error:

... and so on.

I absolutely cannot get any kind of relative file load to work. I've attempted to create a minimal reproducible test case for the issue. The repository is located here: https://github.com/jsonnull/less-modules-resolve.

npm install and npm run build to see the issue.

ERROR in ./~/css-loader?modules!./~/less-loader?sourceMap!./src/index.less
Module not found: Error: Can't resolve 'material-design-icons/MaterialIcons-Regular.ttf' in '/Users/jsonnull/less-modules-resolve/src'
 @ ./~/css-loader?modules!./~/less-loader?sourceMap!./src/index.less 6:470-528
 @ ./src/index.less
 @ ./src/index.js

See below, the file is clearly present:

├── dist
│   └── build.js
├── npm-debug.log
├── package.json
├── src
│   ├── index.js
│   ├── index.less
│   └── material-design-icons
│       ├── LICENSE
│       ├── MaterialIcons-Regular.eot
│       ├── MaterialIcons-Regular.ijmap
│       ├── MaterialIcons-Regular.svg
│       ├── MaterialIcons-Regular.ttf
│       ├── MaterialIcons-Regular.woff
│       ├── MaterialIcons-Regular.woff2
│       ├── README.md
│       ├── codepoints
│       └── material-icons.less
└── webpack.config.js

I've tried every combination for the less file import as well as the url() import I can think of...

  • file - I think this one should work?
  • ./file - I think this one should definitely work
  • ~file - I think this one should not work
  • /file - I think this one should not work

And, anyways, none of these methods work.

Assuming this is possible, how can the repository above be fixed so that all issues are resolved using the current directory structure? Otherwise, are there really combinations of relative paths that are completely impossible to use for importing?

From scrounging through issues it really does seem like nobody has a clear understanding of what this issue is or how to fix it. If we can come up with a clear answer for this issue for why it doesn't work and how to fix, hopefully others can learn from this and we can come up with good documentation for how to avoid this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions