0

enter image description here

I have an action folder inside the src folder as you can see in above pic. I have component file in which I have import statements as below.

import React from "react";
import { connect } from "react-redux";
import "./Login.css";
import * as LoginAction from "../../actions/loginAction";
import rp from "request-promise";
import "bootstrap/dist/css/bootstrap.min.css";

But I am getting error as

/src/Components/LoginComponent.js Module not found: You attempted to import ../../actions/loginAction which falls outside of the project src/ directory. Relative imports outside of src/ are not supported.

Can you please help to find what is wrong here. Thanks in advance.

Nilesh
  • 518
  • 1
  • 9
  • 26
  • I think this [thread](https://stackoverflow.com/questions/44114436/the-create-react-app-imports-restriction-outside-of-src-directory) can help you – EWR Apr 15 '20 at 16:44
  • @EWR it has an answer related to webpack file. In my project I dont have webpack file. – Nilesh Apr 15 '20 at 16:48

1 Answers1

0

When you use ../.. you're trying to access to the parent of parent folder. That's why now you're out of the src folder. And this import is not currently supported.

In your code, try to modify:

import * as LoginAction from "../../actions/loginAction";

to something like one of the followings:

import * as LoginAction from "../actions/loginAction";
import * as LoginAction from "./action/loginAction";
import * as LoginAction from "../redux/actions/loginAction";
nambk
  • 445
  • 3
  • 13