Bundling `index.js` [development, non-minified] 0.0% (0/1), failed.
error: bundling failed: ambiguous resolution: module `C:\Users\mtlok\Desktop\RN2\pep_beta\index.js` tries to require `react-native`, but there are several files providing this module. You can delete or fix them:
* `C:\Users\mtlok\Desktop\RN2\pep_beta\node_modules\react-native-responsive-dimensions\node_modules\react-native\package.json`
* `C:\Users\mtlok\Desktop\RN2\pep_beta\node_modules\react-native\package.json`
捆绑react-native app时出现此错误。
此问题可能是由react-native-responsive-dimensions包
引起的这是package.json文件:
{
"name": "react-native-responsive-dimensions",
"version": "1.0.1",
"description": "Resposive fontSize, height and width for your react-native components.",
"main": "src/index.js",
"scripts": {
"start": "node src/index.js",
"test": "exit 0"
},
"keywords": [
"react-native",
"responsive",
"responsive-height",
"responsive-width",
"responsive-font-size",
"fontSize",
"responsive-dimensions"
],
"author": "DaniAkash <s.daniakash@gmail.com> (https://github.com/DaniAkash)",
"repository": "DaniAkash/react-native-responsive-dimensions",
"license": "MIT",
"dependencies": {
"react-native": "x"
}
}
此外,node_modules文件夹位于node_modules / react-native-responsive-dimensions内。
有快速解决方法吗?
答案 0 :(得分:6)
尝试此命令。也许是因为缓存。
yarn start -- --reset-cache
或
npm start -- --reset-cache
如果它不起作用,您可以尝试react-native-git-upgrade
,或者您可以删除node_modules文件夹,然后运行npm install
,react-native upgrade
和react-native-link
答案 1 :(得分:0)
您可以先卸载react-native-sensitive-dimensions软件包。
npm uninstall react-native-responsive-dimensions --save
然后
yarn start -- --reset-cache or npm start -- --reset-cache
react-native run-android or react-native run-ios