React-native 导入抛出 'Unable to resolve module',即使 IDE 完美地找到它
React-native importing throws 'Unable to resolve module', even though IDE finds it prefectly
这是我在 App.js
中使用的测试导入
import {test} from './utils/configs';
这是我的。/utils/configs:
export const test = 'test-string'
App.js和Utils文件夹在同一层级。 IDE 完美导入,但 Xcode 模拟器抛出错误:
无法从 /Users/riku/Documents/StreamrLabs/streamr-ios-location-poc/App.js
解析模块 ./utils/configs
:无法从 /Users/riku/Documents/StreamrLabs/streamr-ios-location-poc/App.js
找到模块 ./utils/configs
。事实上,none 个文件存在:
/Users/User/Documents/Folder/projectname/utils/configs(.native||.ios.js|.native.js|.js|.ios.json|.native.json|.json)
/Users/User/Documents/Folder/projectname/utils/configs/index(.native||.ios.js|.native.js|.js|.ios.json|.native.json|.json)
似乎导入新模块会中断 Xcode/bundler。我的应用程序是分离的 expo 应用程序。
文件应该有扩展名! (configs.js 在这种情况下)。
Xcode 正在尝试查找 .js 文件,而这里没有扩展名!
(解决方案备案)
import {test} from './utils/configs';
这是我的。/utils/configs:
export const test = 'test-string'
App.js和Utils文件夹在同一层级。 IDE 完美导入,但 Xcode 模拟器抛出错误:
无法从 /Users/riku/Documents/StreamrLabs/streamr-ios-location-poc/App.js
解析模块 ./utils/configs
:无法从 /Users/riku/Documents/StreamrLabs/streamr-ios-location-poc/App.js
找到模块 ./utils/configs
。事实上,none 个文件存在:
/Users/User/Documents/Folder/projectname/utils/configs(.native||.ios.js|.native.js|.js|.ios.json|.native.json|.json)
/Users/User/Documents/Folder/projectname/utils/configs/index(.native||.ios.js|.native.js|.js|.ios.json|.native.json|.json)
似乎导入新模块会中断 Xcode/bundler。我的应用程序是分离的 expo 应用程序。
文件应该有扩展名! (configs.js 在这种情况下)。
Xcode 正在尝试查找 .js 文件,而这里没有扩展名!
(解决方案备案)