所以基本上,我使用 RN 主页中的命令行创建了 React Native with Typescript:\nnpx react-native init MyApp --template react-native-template-typescript
之后,我运行该项目并成功构建。\n但是,当我添加路径别名来导入我的文件时,它引发了错误:Unable to resolve module #folder/file from ... could not be found within the project or in these directories: node_modules
我已经在 Google 上遵循了一些教程和错误解决方案,但我没有遇到任何运气。
\n这是我的.babelrc文件(我尝试将文件从 babel.config.js 更改为 .babelrc 正如某些解析器所说,但它仍然不起作用)
{\n "presets": ["module:metro-react-native-babel-preset"],\n "plugins": [\n [\n "module-resolver",\n {\n "root": ["./src"],\n "extensions": [\n ".js",\n ".jsx",\n ".ts",\n ".tsx",\n ".android.js",\n ".android.tsx",\n ".ios.js",\n ".ios.tsx"\n ],\n "alias": {\n "#src/*": [\n "./src/*"\n ],\n "#configs/*": …Run Code Online (Sandbox Code Playgroud) javascript typescript reactjs react-native babel-plugin-module-resolver