Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

react-native工程 ,引入组件库包后报错:' ERROR Error: Unable to resolve module ../style/public.less #311

Open
1 task
zcq111 opened this issue Jan 3, 2025 · 5 comments

Comments

@zcq111
Copy link

zcq111 commented Jan 3, 2025

启动调试以后,提示 Unable to resolve module ../style/public.less

Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.myapp/.MainActivity }
BUNDLE ./index.js

ERROR Error: Unable to resolve module ../style/public.less from D:\project\MyApp\node_modules@arco-design\mobile-react\esm\style.js:

None of these files exist:

  • node_modules@arco-design\mobile-react\style\public.less(.android.js|.native.js|.js|.android.jsx|.native.jsx|.jsx|.android.json|.native.json|.json|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx)
  • node_modules@arco-design\mobile-react\style\public.less

1 | import '../style/public.less';
| ^
2 | import './tabs/style';
3 | import './sticky/style';
4 | import './portal/style';
at ModuleResolver.resolveDependency (D:\project\MyApp\node_modules\metro\src\node-haste\DependencyGraph\ModuleResolution.js:112:15)
at DependencyGraph.resolveDependency (D:\project\MyApp\node_modules\metro\src\node-haste\DependencyGraph.js:235:43)
at D:\project\MyApp\node_modules\metro\src\lib\transformHelpers.js:160:21
at resolveDependencies (D:\project\MyApp\node_modules\metro\src\DeltaBundler\buildSubgraph.js:42:25)
at visit (D:\project\MyApp\node_modules\metro\src\DeltaBundler\buildSubgraph.js:83:30)
at async Promise.all (index 3)
at async visit (D:\project\MyApp\node_modules\metro\src\DeltaBundler\buildSubgraph.js:92:5)
at async Promise.all (index 5)
at async visit (D:\project\MyApp\node_modules\metro\src\DeltaBundler\buildSubgraph.js:92:5)
at async Promise.all (index 2)
BUNDLE ./index.js

ERROR app\pages\customer\index.tsx: Unknown option: .modulePaths. Check out https://babeljs.io/docs/en/babel-core/#options for more information about options.
BUNDLE ./index.js

ERROR app\pages\customer\index.tsx: Unknown option: .modulePaths. Check out https://babeljs.io/docs/en/babel-core/#options for more information about options.

package.json引用如下:

"devDependencies": {
"@babel/core": "^7.25.2",
"@babel/preset-env": "^7.25.3",
"@babel/runtime": "^7.25.0",
"@react-native-community/cli": "15.0.1",
"@react-native-community/cli-platform-android": "15.0.1",
"@react-native-community/cli-platform-ios": "15.0.1",
"@react-native/babel-preset": "0.76.5",
"@react-native/eslint-config": "0.76.5",
"@react-native/metro-config": "0.76.5",
"@react-native/typescript-config": "0.76.5",
"@types/react": "^18.2.6",
"@types/react-test-renderer": "^18.0.0",
"babel-jest": "^29.6.3",
"babel-plugin-import": "^1.13.8",
"babel-plugin-module-resolver": "^5.0.2",
"eslint": "^8.19.0",
"jest": "^29.6.3",
"prettier": "2.8.8",
"react-test-renderer": "18.3.1",
"typescript": "5.0.4"
},
"peerDependencies": {
"react": ">=16.9.0",
"react-dom": ">=16.9.0",
"react-transition-group": ">=4.3.0"
},

babel.config.js引用如下:

module.exports = {
presets: ['module:@react-native/babel-preset'],

plugins: [
[
'module-resolver',
{
root: ['./app'],
extensions: ['.ios.js', '.android.js', '.js', '.ts', '.tsx', '.json'],
alias: {
'@': ['./app'],
}
}
],
["import", {
"libraryName": "@arco-design/mobile-react",
"libraryDirectory": "esm", // 注意如果是 SSR 环境,这里需使用 cjs
"style": (path) => ${path}/style
}, "@arco-design/mobile-react"],
["import", {
"libraryName": "@arco-design/mobile-react/esm/icon", // 注意如果是 SSR 环境,这里需将 esm 替换为 cjs
"libraryDirectory": "",
"camel2DashComponentName": false
}, "@arco-design/mobile-react/esm/icon"]
]

};

@zcq111
Copy link
Author

zcq111 commented Jan 3, 2025

启动调试以后,提示 Unable to resolve module ../style/public.less

@shenhaidada
Copy link
Collaborator

项目有使用less-loader等处理less文件吗

@zcq111
Copy link
Author

zcq111 commented Jan 4, 2025

有用到less文件

@zcq111
Copy link
Author

zcq111 commented Jan 4, 2025

是不是arco-design-mobile不支持react-native?

@shenhaidada
Copy link
Collaborator

对的,目前不支持哦,全局会有一些用到web相关的代码

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants