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.

Cant resolve modules

See original GitHub issue

In webpack config we have: resolve: { modules: [path.resolve(__dirname, '../src'), 'node_modules'], } But when import Link from 'components/Link' Found error: Error: Cannot find module 'components/Link'

Issue Analytics

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

github_iconTop GitHub Comments

2reactions
frenzzycommented, Mar 15, 2017

sure, for example if you want to make import Header from 'src/components/Header' works:

// tools/webpack.config.js

// ...

const clientConfig = {
  // ...
  resolve: {
    modules: [path.resolve(__dirname, '..'), 'node_modules'],
  },
  // ...
};

const serverConfig = {
  // ...
  resolve: {
    modules: [path.resolve(__dirname, '..'), 'node_modules'],
  },
  externals: [
    /^\.\/assets\.json$/,
    (context, request, callback) => {
      const isExternal =
        request.match(/^[@a-z][a-z/.\-0-9]*$/i) &&
        !request.match(/^src\//i) && // module is not external if starts with `src/`
        !request.match(/\.(css|less|scss|sss)$/i);
      callback(null, Boolean(isExternal));
    },
  ],
  // ...
};

// ...
1reaction
frenzzycommented, Mar 13, 2017

oops, was a wrong link)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Can't resolve module (not found) in React.js - Stack Overflow
It seems you need import Header from './components/header/header' w/o src. File path is relative to importing file path. Then you need to export ......
Read more >
How to configure webpack to fix "Can't resolve 'module' from ...
I'm having a hard time to run babel-plugin-macros with a storybook, it seems I need to configure the webpack: I asked the same...
Read more >
Module not found: Can't resolve 'X' error in React | bobbyhadz
To solve the "Module not found: Can't resolve" error in React, make sure to install the package from the error message if it's...
Read more >
How to fix 'Module not found: Error: Can't resolve'?
In this article, we're talking about the "module not found: Error: can't resolve" problem and giving you three fixes to resolve the error....
Read more >
Have a JavaScript Module Not Found Error ... - Airbrake Blog
If you see a “Module not found: error can't resolve” JavaScript error, there's likely a problem with the communication between the module you're...
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