【发布时间】:2018-09-17 05:06:15
【问题描述】:
我有两个反应应用程序(A-app,B-app)。我需要将一个组件从 A-app 导入到 B-app。 但是当我尝试这样做时,我看到了这个错误。
./src/App.js
Module not found: You attempted to import ../../src/components/Dashboard/container 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/.
我尝试在 B-app node_modules 中对这个组件进行符号链接。但它没有用。
我还尝试在根项目目录中创建 .env 文件并将其放入 NODE_PATH=src/
在文件中。但是这个解决方案也不起作用。
我该如何解决这个问题?
对不起我的英语。
【问题讨论】:
-
为什么创建符号链接不起作用?你得到了什么错误?
-
如果我创建了符号链接,我会看到
Module not found: You attempted to import ../../src/components/Dashboard/container 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/。我认为 its because I havent .min 在我的组件中。
标签: javascript reactjs ecmascript-6