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 resolve suggestion

See original GitHub issue

Consider adding the src directory to the list of webpack module resolves. This makes imports throughout your app simpler.


import Thing from "../../../util/Thing";


import Thing from "util/Thing";

This also makes moving files around easier since you don’t have to change the relative paths.

You can already accomplish this today by making an env file and putting NODE_PATH=src in it. But it seems like a pretty smart default that CRA could set for people.

Something like this would do it:

resolve: {
  modules: ['node_modules', path.resolve(`${__dirname}/src`)]

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

Timercommented, Aug 2, 2017

We are not making this a default any time soon. There are too many cases where it causes confusing behavior. Setting NODE_PATH=src inside .env is the best solution currently.

FYI, you are supposed to commit your .env files (minus .local) so that your teammates have them (in case you were telling them to do this by hand).

ZoeDreamscommented, Oct 12, 2017

in previous projects we have generated a local.env.sample (or commit it) and then have the install or build scripts warn the developer if the local.env is missing and using environment variables instead.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Resolving require paths with webpack - Stack Overflow what if I only want modules to be resolved from the current project? I have a few projects that import from each...
Read more >
Suggest changes - GitLab Docs
The suggestion is marked as Applied. The thread is resolved. GitLab creates a new commit with the changes. If the user has the...
Read more >
CommonJS modules | Node.js v19.3.0 Documentation
Below we give a suggested directory structure that could work: ... Since modules may resolve to a different filename based on the location...
Read more >
TSConfig Reference - Docs on every TSConfig option
undefined (default) provide suggestions as warnings to editors; true unreachable code is ignored ... There is a handbook reference page on Module Resolution....
Read more >
@tiptap/suggestion - npm
suggestion plugin for tiptap. Latest version: 2.0.0-beta.209, last published: 6 days ago. Start using @tiptap/suggestion in your project by ...
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 Post

No results found

github_iconTop Related Hashnode Post

No results found