ant-design / ant-design-mobile-rn

Ant Design for React Native
https://rn.mobile.ant.design/
MIT License
3.04k stars 612 forks source link

Error: undefined Unable to resolve module antd-mobile/dist/antd-mobile.less from D:\LinkSpace\Work\WorkSpace\Code\WebStorm\ReactPro\USDTWalletApp\App.js: antd-mobile/dist/antd-mobile.less could not be found within the project or in these directories: node_modules #1166

Closed Fcscanf closed 3 years ago

Fcscanf commented 3 years ago

Reproduction link

https://u.ant.design/codesandbox-repro

Steps to reproduce

  1. npx react-native init AwesomeProjectCommand creates the project

  2. $ npm install antd-mobile --saveCommand adds a UI component

  3. import 'antd-mobile/dist/antd-mobile.css';

  4. image

  5. config plugin

    // .babelrc or babel-loader option
    {
    "plugins": [
    ["import", { libraryName: "antd-mobile", style: "css" }] // `style: true` 会加载 less 文件
    ]
    }

    image

  6. Start error [Error: undefined Unable to resolve module antd-mobile/dist/antd-mobile.less from D:\LinkSpace\Work\WorkSpace\Code\WebStorm\ReactPro\USDTWalletApp\App.js: antd-mobile/dist/antd-mobile.less could not be found within the project or in these directories: node_modules

If you are sure the module exists, try these steps:

  1. Clear watchman watches: watchman watch-del-all
  2. Delete node_modules and run yarn install
  3. Reset Metro's cache: yarn start --reset-cache
  4. Remove the cache: rm -rf /tmp/metro-* 27 | } from 'react-native/Libraries/NewAppScreen'; 28 | import Login from './src/component/login';

    29 | import 'antd-mobile/dist/antd-mobile.less'; | ^ 30 | 31 | const Section = ({children, title}): Node => { 32 | const isDarkMode = useColorScheme() === 'dark';] image

What is expected?

Normal display style

What is actually happening?

 ERROR  [Error: undefined Unable to resolve module antd-mobile/dist/antd-mobile.less from D:\LinkSpace\Work\WorkSpace\Code\WebStorm\ReactPro\USDTWalletApp\App.js: antd-mobile/dist/antd-mobile.less could not be found within the project or in these directories:
  node_modules

If you are sure the module exists, try these steps:
 1. Clear watchman watches: watchman watch-del-all
 2. Delete node_modules and run yarn install
 3. Reset Metro's cache: yarn start --reset-cache
 4. Remove the cache: rm -rf /tmp/metro-*
  27 | } from 'react-native/Libraries/NewAppScreen';
  28 | import Login from './src/component/login';
> 29 | import 'antd-mobile/dist/antd-mobile.less';
     |         ^
  30 |
  31 | const Section = ({children, title}): Node => {
  32 |   const isDarkMode = useColorScheme() === 'dark';]
Environment Info
antd 4.14.0
React 17.0.1
System Win10
Browser 89.0.4389.90(正式版本)

The project structure is as follows image