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

ESLint 报错 Unable to resolve path to module 'antd-mobile' import/no-unresolved #523

Closed
xwartz opened this issue Nov 14, 2016 · 14 comments

Comments

@xwartz
Copy link

xwartz commented Nov 14, 2016

本地环境

Mac

antd-mobile: 0.9.4

ESLint: 2.10.1

babel-eslint: 6.0.4

在 react-native 中使用

你做了什么?

引入模块

import { Popup } from 'antd-mobile'

ESLint parse 使用的是 babel-eslint

你期待的结果是:

ESLint 不报错

实际上的结果:

Unable to resolve path to module 'antd-mobile' import/no-unresolved

@xwartz xwartz changed the title Eslint 报错 Unable to resolve path to module 'antd-mobile' import/no-unresolved ESLint 报错 Unable to resolve path to module 'antd-mobile' import/no-unresolved Nov 14, 2016
@warmhug
Copy link
Contributor

warmhug commented Nov 14, 2016

#414 #56 #510

@warmhug
Copy link
Contributor

warmhug commented Nov 14, 2016

仔细对照看文档。

@xwartz
Copy link
Author

xwartz commented Nov 15, 2016

感谢回复,在提这个 issue 之前我已经搜索过相关问题,没有 eslint 相关的。
麻烦再看一下我的问题,谢谢。

@warmhug
Copy link
Contributor

warmhug commented Nov 15, 2016

@xwartz
Copy link
Author

xwartz commented Nov 15, 2016

你意思是使用

"import/no-unresolved": 0

这个规则吗?

如果是这样的话,并不认为是好的解决方案

@warmhug
Copy link
Contributor

warmhug commented Nov 15, 2016

欢迎你提供更好的方案建议~

@afc163
Copy link
Member

afc163 commented Nov 15, 2016

把默认的 main 设为 lib/index.jslib/index.web.js

@xwartz
Copy link
Author

xwartz commented Nov 15, 2016

@afc163 额,没懂你说的 main 指的是什么

@afc163
Copy link
Member

afc163 commented Nov 16, 2016

我是和 @warmhug 说的。

@xwartz
Copy link
Author

xwartz commented Nov 25, 2016

有什么进展吗

@xwartz
Copy link
Author

xwartz commented Nov 25, 2016

目前暂时在引入 antd 的地方使用 eslint-disable-line

@yoniji
Copy link

yoniji commented Dec 1, 2016

@xwartz
.eslintrc 中可以这样设置

  "rules": {
    "import/extensions": [2, "never", { "web.js": "never", "json": "never" }],
    "import/no-extraneous-dependencies": [2, { "devDependencies": true }],
    "import/no-unresolved": [2, { "ignore": ["antd-mobile"] }]
  }

"import/no-extraneous-dependencies" 和 "import/extensions" 的设置和本问题无关,只是现在的我们的项目里 "import/no-unresolved" 和 "import/no-extraneous-dependencies" 都设置为 0 不妥当

@xwartz
Copy link
Author

xwartz commented Dec 1, 2016

@yoniji 谢谢,你的方式比我的好多了

@lock
Copy link

lock bot commented May 28, 2018

This thread has been automatically locked because it has not had recent activity. Please open a new issue for related bugs and link to relevant comments in this thread.

@lock lock bot locked as resolved and limited conversation to collaborators May 28, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants