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.

Module not found: Can't resolve 'module'

See original GitHub issue

Can’t resolve ‘module’

When linking a dependency locally that uses module-alias, I’m getting the error below:

Module not found: Can't resolve 'module' in '/Users/inje/Docs/repos/setprotocol.js/node_modules/module-alias'

How to Reproduce

  1. Have a locally cloned repo of your dependency and build your package.
  2. Run yarn link to create your symlinked package
  3. In your depender repo, run yarn link my-package-name
  4. In the depender repo, run your code yarn start
screen shot 2018-10-01 at 2 19 12 pm

Extra details

  • The dependee library using module-alias is using typescript
  • The depender repo is a React app linking the dependee library locally. It’s also using typescript

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:15
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
ilearniocommented, Feb 15, 2019

@Fensterbank Are you sure you are running it using Nodejs? Because some people have problems running it in Meteor or other environments.

I tried to create a simple file with

// test.js
require('module-alias/register')

And calling it with node ./test.js works

0reactions
Kehrlanncommented, Feb 15, 2019

Ok I looked into it. It definitely works in pure Node, see proof of concept: https://github.com/Kehrlann/module-alias-yarn-link

No need for module-alias in a TypeScript project, you can use tsconfig’s paths, see: https://blog.joefallon.net/2018/02/using-short-imports-in-typescript/ … you app being React, it will very likely run through a Webpack step, which also have it’s own module-aliasing capabilities: https://webpack.js.org/configuration/resolve/ . I’m no sure module-alias is the right solution for you.

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 >
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 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 - Next.js
Why This Error Occurred · The module you're trying to import is not installed in your dependencies · The module you're trying to...
Read more >
cannot find module [Node npm Error Solved] - freeCodeCamp
How to Fix the "cannot find module" Error · delete the node modules folder by running rm -rf node_modules · delete package.lock.json file...
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