eslint-plugin-import: import/no-unresolved is not recognizing installed modules that export "."
All dependencies are on their latest versions. Errors:
1:39 error Unable to resolve path to module '@vue/test-utils' import/no-unresolved
4:29 error Unable to resolve path to module 'vuex' import/no-unresolved
Code:
import { createLocalVue, mount } from '@vue/test-utils';
import axios from 'axios';
import flushPromises from 'flush-promises';
import Vuex, { Store } from 'vuex';
import { mutations } from '@/store.js';
import App from '@/App.vue';
import { currentUser } from '@@/mockData/CommonMockData.js';
import mockUsersResponse from '@@/mockResponses/Users.js';
vuex is in the dependencies and @vue/test-utils is in the devDependencies in package.json. Both are installed and in the node_modules folder.
What’s interesting is that they fail across all test files, but no other node_module imports fail. It’s just these two.
eslintrc.js
const path = require('path');
module.exports = {
root: true,
parserOptions: {
parser: '@babel/eslint-parser',
ecmaVersion: 2022,
sourceType: 'module',
requireConfigFile: false
},
extends: [
'tjw-import'
],
settings: {
'import/resolver': {
webpack: {
config: {
resolve: {
alias: {
'@': path.resolve(__dirname, 'src'),
'@@': path.resolve(__dirname, 'tests')
}
}
}
}
}
}
};
tjw-import can be seen here:
About this issue
- Original URL
- State: open
- Created a year ago
- Reactions: 9
- Comments: 17 (6 by maintainers)
@ljharb See #1479
Updated previous example to answer question
Do they have a “main”, though?
This plugin uses
resolve, which does not yet support “exports”.Yeah it’s the missing
"main"field which causes an error onsql-template-tagpackage which appears to be ESM only and only has anexportsset in the package.json👋 Just noting that I ran into this with
graphql-requestas well, which only hasexportsand notmain:issue occurs also with avajs
Thank you for the head up @ljharb No
"main"neither in@multiformats/multiaddrI looked at theresolvesource it seems neither the legacy"module"nor"exports"is supported From Node.js 12 having only"exports"is fine,"main"is only used as a fallback when the former is missing. Since the oldest Node.js maintained LTS is 14"exports"should be the default resolution.Updated issue title based on this new information.
hey, I’m running into the same issue while importing
@multiformats/multiaddrthe issue may comes from nested export of
"."@vue/test-utils@multiformats/multiaddrthis syntax look good according to nodejs doc https://nodejs.org/docs/latest-v16.x/api/packages.html#package-entry-points but is no resolved by
eslint-plugin-importThe
flush-promisesandaxiosimports do not have a linting error, and do not haveexportsormoduledefined in theirpackage.json.