Невозможно разрешить модуль `. / Index.css` из` node_modules / antd-mobile / lib / button / style / css .js` - PullRequest
0 голосов
/ 14 апреля 2020

Я пытаюсь использовать компоненты Ant Design Mobile https://mobile.ant.design/docs/react/introduce в реактивном собственном проекте, созданном с использованием init-native init. Я пытался поместить код плагина antd-mobile babel в файл .babelr c, к сожалению, он не работает.

, когда я запускаю yarn ios, я получаю эту ошибку

Unable to resolve module `./index.css` from `node_modules/antd-mobile/lib/button/style/css.js`: 

None of these files exist:
  * node_modules/antd-mobile/lib/button/style/index.css(.native|.ios.js|.native.js|.js|.ios.json|.native.json|.json|.ios.ts|.native.ts|.ts|.ios.tsx|.native.tsx|.tsx)
  * node_modules/antd-mobile/lib/button/style/index.css/index(.native|.ios.js|.native.js|.js|.ios.json|.native.json|.json|.ios.ts|.native.ts|.ts|.ios.tsx|.native.tsx|.tsx)

RCTFatal
__28-[RCTCxxBridge handleError:]_block_invoke
_dispatch_call_block_and_release
_dispatch_client_callout
_dispatch_main_queue_callback_4CF
__CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__
__CFRunLoopRun
CFRunLoopRunSpecific
GSEventRunModal
UIApplicationMain
main
start

App.js

import React from 'react';
import {Text, View} from 'react-native';

import {Button} from 'antd-mobile';


const App = () => {
   return (
    <View><Button><Text>CustomButton</Text></Button></View>
   );
};
export default App;

babel.config.js

module.exports = {
  presets: ['module:metro-react-native-babel-preset'],
  plugins: [
    ["import", { "libraryName": "antd-mobile", "style": "css" }] // `style: true` for less
  ]
};

package.json

{
  "name": "client",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "android": "react-native run-android",
    "ios": "react-native run-ios --simulator='iPhone 8'",
    "start": "react-native start",
    "test": "jest",
    "lint": "eslint ."
  },
  "dependencies": {
    "@ant-design/react-native": "^3.3.0",
    "antd-mobile": "^2.3.1",
    "babel-plugin-import": "^1.13.0",
    "react": "16.11.0",
    "react-native": "0.62.2"
  },
  "devDependencies": {
    "@babel/core": "^7.6.2",
    "@babel/runtime": "^7.6.2",
    "@react-native-community/eslint-config": "^0.0.5",
    "babel-jest": "^24.9.0",
    "eslint": "^6.5.1",
    "jest": "^24.9.0",
    "metro-react-native-babel-preset": "^0.58.0",
    "react-test-renderer": "16.11.0"
  },
  "jest": {
    "preset": "react-native"
  }
}
...