简体   繁体   English

从同一目录中文件夹中的文件中的 node_modules 导入

[英]import from node_modules from file in folder in same directory

I have the following file structure:我有以下文件结构:

-/
   - node_modules/
   - src/
     - App.tsx

Now from App.tsx I want to import from react with import {View, Component} from "react-native" .现在我想从App.tsx导入 from react with import {View, Component} from "react-native" This however doesnt work, but of course it does with the path "../node_modules/react-native" .然而,这不起作用,但当然它适用于路径"../node_modules/react-native" How can I achieve to import from react-native in all files in src without having to write "../node-modules/" before everything I want to import from react-native ?我怎样才能实现从react-native导入src中的所有文件,而不必在我想从react-native导入的所有内容之前写"../node-modules/"

seems like my node_modules configuration was not correct, simply removing and reinstalling them solved the problem.似乎我的node_modules配置不正确,只需删除并重新安装它们即可解决问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM