node.js - Eslint plugin import throws "import/no-unresolved" on specific modules inside a Lerna package
问题描述
I'm using Lerna for the first time, and I want to create a monorepo of microservices, so inside a service I have axios, puppeter & joi installed, so eslint-plugin-import takes them as unresolved because they are not in the root package.json
I don't know how to change my current Eslint config, and I'm pretty sure that I don't need to create an Eslint config for every service inside packages folder, because I have seen repos with lerna that do not do that
I'm using Airbnb's rules
"eslint": "5.3.0",
"eslint-config-airbnb": "17.1.0",
"eslint-plugin-import": "2.16.0",
"eslint-plugin-jsx-a11y": "6.2.0",
"eslint-plugin-react": "7.12.4",
And, this is my .eslintrc
{
"extends": "airbnb",
"rules": {
"no-unused-vars": [
"error",
{
"argsIgnorePattern": "next"
}
]
},
"env": {
"browser": true,
"es6": true,
"mocha": true,
"node": true
}
}
~/api-gateway/packages/service-accountancy/lib/scrapper.js 2:27 error Unable to resolve path to module 'puppeteer' import/no-unresolved 3:22 error Unable to resolve path to module 'puppeteer/lib/Page' import/no-unresolved
~/api-gateway/packages/service-accountancy/src/api/api.js 2:21 error Unable to resolve path to module 'joi' import/no-unresolved
~/api-gateway/packages/service-accountancy/src/repository/repository.js 2:23 error Unable to resolve path to module 'axios' import/no-unresolved
~/api-gateway/packages/service-accountancy/src/schemas/portalRequest.js 1:21 error Unable to resolve path to module 'joi' import/no-unresolved
解决方案
The eslint-plugin-import package was actually doing its job, those packages were no downloaded at the time Eslint was running
推荐阅读
- sql - 如何在不使用内置函数的情况下在 Teradata sql 中获得这种类型的结果
- python - 如何在取平均值的同时合并日期时间列上的值
- c - “警告:除以零 [-Wdiv-by-zero]”当不除以零时
- reactjs - 列内带有下拉菜单的材料 UI 表
- javascript - Jquery切换图标显示越来越少
- sql - 对于可选的请求字段值,是否有任何 SQL 语句过程或代码?
- c++ - TLS 双向相互身份验证不起作用,因为客户端未发送其证书
- ruby-on-rails - after_rollback on :create 未触发
- react-native - 在本机反应中显示来自 URL 的外部 SVG 图像
- python - 监控 scikit 的 DBSCAN 的进度