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.

Importing Less file into component throws package not declared in dependencies error

See original GitHub issue

This doesn’t really fit a bug template, I am just looking for guidance on this issue I’m facing. I am using a Next.js application and in my webpack config I have the following alias defined:

module.exports = {
    webpack(config) {
        // Setting up alias for absolute imports
        config.resolve.alias['@Components'] = path.join(__dirname, 'components');
        return config;
    }
};

This allows me to import components anywhere in my application from that folder like so:

import Button from '@Component/Button`

When using Yarn 2, I get the following error message:

./components/Button/index.js
Module not found: Something that got detected as your top-level application (because it doesn't seem to belong to any package) tried to access a package that is not declared in your dependencies

Any suggestion on how to resolve this issue? Prior to switching to Yarn 2, it was working well. Thanks.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
Kinbaumcommented, Apr 9, 2020

Update, so I forked the next-css and next-less repos and updated their loaders to use require.resolve. That seems to have resolved the issue.

1reaction
merceyzcommented, Apr 3, 2020

Just to make sure, did you run yarn after adding it?

Read more comments on GitHub >

github_iconTop Results From Across the Web

vue.js - Importing lib's css inside the component styles is ...
However when I import the styles it throws a loader error about dependency not found. What is wrong and how can I fix...
Read more >
no-extraneous-dependencies doesn't support nested package ...
Run 'npm i -S react' to add it import/no-extraneous-dependencies 2:1 error 'classnames' should be listed in the project's dependencies.
Read more >
Docs • Svelte
Complete documentation for Svelte.
Read more >
API - esbuild
To join a set of files together with esbuild, import them all into a single entry point file and bundle just that one...
Read more >
Migrating from v2 to v3 - Gatsby
Part of that huge ecosystem includes dependency trees! Depending on how the plugin authors have declared dependencies (e.g. marking a package as a...
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