我正在尝试使用针对react-native
平台的图表的victory-native包。我已使用victory-native
命令安装了react-native-svg
和--save
。然后我还将它们与
react-native link
但现在当我执行react-native start
时会抛出以下错误:
error: bundling failed: Error: While trying to resolve module `react-native-
svg` from file `/Users/keshav/projects/PropertyFinder/node_modules/victory-
native/lib/components/victory-primitives/line.js`, the package
`/Users/keshav/projects/PropertyFinder/node_modules/react-native-svg/package.json` was successfully found. However, this package itself specifies a `main` module field that could not be resolved
(`/Users/keshav/projects/PropertyFinder/node_modules/react-native-svg/index.js`. Indeed, none of these files exist:
* `/Users/keshav/projects/PropertyFinder/node_modules/react-native-svg/index.js(.native||.android.js|.native.js|.js|.android.json|.native.json|.json)`
* `/Users/keshav/projects/PropertyFinder/node_modules/react-native-svg/index.js/index(.native||.android.js|.native.js|.js|.android.json|.native.json|.json)`
at ResolutionRequest.resolveDependency
(/Users/keshav/projects/PropertyFinder/node_modules/metro/src/node-
haste/DependencyGraph/ResolutionRequest.js:104:15)
```
我的package.json:
"react": "16.3.0-alpha.2",
"react-native": "0.54.2",
"react-native-svg": "^6.3.0",
"react-navigation": "^1.5.7",
"simple-swizzle": "^0.2.2",
"superagent": "^3.8.2",
"victory-native": "^0.17.2"
这里有什么问题?
答案 0 :(得分:0)
我遇到了同样的问题。但不同的是我使用了'react-native-tab-navigator'。我尝试过多次不同的方式,直到我重新启动Xcode并重建项目。我希望这可以帮助你
答案 1 :(得分:0)
晚了聚会,但我不得不按如下方式修改我的metro.config.js
文件:
module.exports = {
...
resolver: {
sourceExts: ['js', 'jsx', 'ts', 'tsx']
}
}
我认为这是为了帮助Metro解决js,jsx等之外的路径。