Failed to compile.
Module not found: Error: You attempted to import ../components/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/.
ERROR in ./src/index.js 6:0-36
Module not found: Error: You attempted to import ../components/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/.
webpack compiled with 1 error
我得到上述错误时,我试图运行我的react应用程序。我正在学习和初学者在react js。我正在学习Map在reactjs和当我运行我的应用程序,我得到这个错误的任何人请解决这个问题。
文件系统分配如下。
2条答案
按热度按时间bq3bfh9z1#
使用
import App from "./components/App"
代替import App from "../components/App";
7vhp5slm2#
../
意味着你想从你的文件所在的文件夹中退出.这意味着../
将你带到mapping
下,所以你像这样导入但最好不要出去使用
./
,而是停留在src
下,并像这样导入:都是对的。