3gwebtrain
3gwebtrain

Reputation: 15303

ReactJS - '.env' file not works as expected

I added a .env file with my project as : NODE_PATH=src/ - so later on I import the components like:

import Subtitle from "Components/Subtitle"; 

instead of regular approach as import Subtitle from "./Components/Subtitle"; since .env added the path. But still not works as expected.

What is the mistake here i do? How to define the base path, if this is wrong? Any one help me here?

Live Demo

Upvotes: 0

Views: 92

Answers (1)

n1stre
n1stre

Reputation: 6086

  1. You have a typo. Rename .evn to .env.
  2. Ensure that you don't have any spaces in .env file. In your case it should be NODE_PATH=src/.

And here's forked codesandbox

Upvotes: 1

Related Questions