Linting issue with imports

I am unable to resolve the linting issue “import/no-unresolved” if using import statements like this

import { xxx } from '/client/xxx/yyy’
import { xxx } from ‘/server/xxx/yyy’

Thanks in advance for help.

This linting error just tells you that the file you’re trying to import cannot be found.
See here.

Are you sure you’re pointing at the right location?

Obviosuly this can also happen if you’re writing your test first (i.e. TDD) and implement the actual code afterwards. In this case, that lint warning would be expected.

Actually the files are there and there is no linting errors when using the relative path for e.g.

import xxx from '../client/xxx';

The linting errors are only occurring when using the following import statements.

import xxx from '/client/xxx'; { this works only linting issue }

Ah ok.
Well I’m no expert, but Meteor’s final paths (after build) may be different than what your linter is looking at - especially if you’re using absolute paths as in your second example.

So I’d definitely recommend using relative paths only.

And simply silencing the linter is out of the question? Otherwise you could “fix” it with the solution @will is providing here:

I did silence it with the linter but i was just looking out if there is another way or somebody has written a resolver for the import plugin.

Looks like there’s some work being done on this; new as of 2 days ago:

1 Like

Good catch, I updated my boilerplate code to use it thanks it just needs one more tweak namely support meteor/ I opened up an issue already

Found it:

// .eslintrc
"rules": {
    "import/no-unresolved": [2, {ignore: ["^meteor/"]}],

How do you deal with imports of folders?

such as

import '/imports/startup/client';

I’m not sure exactly what you’re asking. What are you expecting to happen with that statement and what is ESLint doing that is violating that expectation?

I think it was an issue with absolute vs relative path…in any case it fixed itself after installing


Sorry for not closing not editing the comment