如何导入一个文件3个文件夹下来



我正在编辑一个文件Product.jsx,文件路径为:srccomponentsProductsProductProduct.jsx

我想导入一个CartContext文件,路径为:srccontextCartContext.js

我正在尝试这样做:import { CartContext } from "../../../context/CartContext";导入它,但我得到错误:

Failed to compile
./src/components/frontpage/Product.js
Module not found: You attempted to import ../../../context/CartContext which falls outside of the project src/ directory. 
Relative imports outside of src/ are not supported.

我从来没有导入错误,我不知道发生了什么。

自动导入也不起作用。。

原来我编辑了错误的文件,该文件位于src\components\frontpage\Product.js中,导致;落在项目src/目录之外";错误

最新更新