Create react app with absolute imports (`NODE_PATH`)
See original GitHub issueQuestion
Description
Reading #140 I get the impression that NODE_PATH
in .env
should be supported.
I’ve gotten a create-react-app until the point of supporting absolute paths. Is there any way to tell docz to use src
as NODE_PATH
?
Steps to reproduce
I’ve created an example in https://github.com/KATT/create-react-app-docz-test
git clone git@github.com:KATT/create-react-app-docz-test.git
cd create-react-app-docz-test
yarn docz:dev
Error
This dependency was not found:
* components/Logo in ./src/components/App/index.js
Note
The example project works if we revert eaba11.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:4
- Comments:8 (2 by maintainers)
Top Results From Across the Web
Absolute imports with Create React App | by David Gilbertson
With the release of Create React App 3, we now have the ability to use absolute import paths, without ejecting. If you're reading...
Read more >Absolute Path Imports · Issue #4928 · facebook/create-react-app
According to the links below I understand .env with NODE_PATH=src in it, allows the react app to take advantage of Absolute Path Imports...
Read more >Absolute imports in Create React App - DEV Community
Absolute imports can help you make that code a lot cleaner, more readable and manageable. We want to be able to transform our...
Read more >Using Absolute Imports in React TypeScript Projects
Importing using relative paths can get pretty ugly quickly. Learn how to use absolute paths to make importing files easier.
Read more >Absolute Imports: React and Typescript - Stack Overflow
I have a React app bootstrapped using create-react-app and typescript. As the application has grown, (goal) I would like to implement absolute ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hello @KATT I’ve the same problem. For the moment, I found this solution changing the babel configuration of docz.
First install the babel plugin babel-plugin-module-resolver
Next, create (if you don’t have it) the docz configuration file named
doczrc.js
and add:You can use the variable
process.env.NODE_PATH
instead of the string'./src'
.Launched on v0.13.0 ✅