typescript - 未找到模块:无法解析“D:\FoodOderingApp\Client\screens\Item Listing”中的“components/Card Container/CardContainer”
问题描述
{
"compilerOptions": {
"target": "es6",
"strictNullChecks": true,
"allowSyntheticDefaultImports": true,
"jsx": "react-native",
"lib": ["dom", "esnext"],
"moduleResolution": "node",
"noEmit": true,
"skipLibCheck": true,
"allowJs": true,
"resolveJsonModule": true,
"strict": true,
"baseUrl": "./",
"types": ["node"],
"paths": {
"helper/*": ["Helper/*"],
"header/*": ["components/Header/*"],
"components/*": ["components/*"],
"navigation/*": ["navigation/*"],
"screens/*": ["screens/*"],
"states/*": ["State/*"]
},
"include": ["./Client/**/*"]
}
}
文件结构
- 客户
- 组件
- 标题 - 帮手
- 导航
- 屏幕
- 状态
即使我可以单击我的特定 .tsx 文件,我也找不到该模块
解决方案
{
"compilerOptions": {
"outDir": "../public",
"module": "esnext",
"target": "es5",
"sourceMap": true,
"noEmit": true,
"skipLibCheck": true,
"allowJs": true,
"jsx": "react-native",
"lib": ["dom", "esnext"],
"moduleResolution": "node",
"noImplicitReturns": true,
"noImplicitThis": true,
"noImplicitAny": true,
"strictNullChecks": true,
"baseUrl": "./",
"rootDir": "./",
"typeRoots": ["./node_modules/@types", "./src/@types"],
"paths": {
"@helper/*": ["Helper/*"],
"@header/*": ["components/Header/*"],
"@components/*": ["components/*"],
"@navigation/*": ["navigation/*"],
"@screens/*": ["screens/*"],
"@states/*": ["State/*"]
},
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
"importsNotUsedAsValues": "preserve",
"include": ["./Client/**/*"]
}
}
当您确实要导入时,可以通过两种方式进行。
- 和
*
"@screens/*":["screens/*"],
进口:
import ItemListing from '@screen/'
- 如果我们
*
从路径中移除
"@screens/":["screens/*"],
然后你可以像这样导入:
import ItemListing from '@screen'
推荐阅读
- python - 没有完整路径,python 无法从 pycharm windows 终端启动
- neovim - 当我引入需要“ALTGR”键的符号时,Nvim 没有引入正确的符号
- audio - 谷歌云语音到某些短词的文本困难
- javascript - 如何将 onchange 事件绑定到特定行的元素?
- html - Select2 Bootstrap 主题 如何修复不正确的样式显示?
- swift - ForegroundColor SwiftUI 上的 If else 语句
- c++ - (cmake, swig) 链接器错误 (ld: symbol(s) not found for architecture x86_64)
- elixir - 处理phoenix elixir中的模式匹配异常
- php - laravel 中未定义的变量 $menus
- python-3.x - 如何在 python 文件中加入多行