Home > Blockchain >  Module not found: Error: You attempted to import , problems with relative import
Module not found: Error: You attempted to import , problems with relative import

Time:02-07

ERROR in ./src/index.js 7:0-30

Module not found: Error: You attempted to import ../main/App which falls outside of the project src/ directory. Relative imports outside of src/ are not supported. You can either move it inside src/, or add a symlink to it from project's node_modules/.

import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import App from '../main/App';              (**My problem is here**)
import reportWebVitals from './reportWebVitals';

ReactDOM.render(
  <React.StrictMode>
    <App />
  </React.StrictMode>,
  document.getElementById('root')
);

CodePudding user response:

I guess the solution is in error so bring your App.js or main folder inside of the src folder and then it works

import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import App from '../main/App';  
import reportWebVitals from './reportWebVitals';

ReactDOM.render(
  <React.StrictMode>
    <App />
  </React.StrictMode>,
  document.getElementById('root')
);
  •  Tags:  
  • Related