question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

import/no-unresolved requires installed node_modules

See original GitHub issue

It seems that import/no-unresolved will complain for valid import statements if node_modules isn’t present or it’s outdated.

When using a complex build system, npm install is often executed inside a build system sandbox and node_modules might never be present in the original repository where eslint runs (e.g. through IDEs).

Is there a way to prevent import/no-unresolved from complaining about valid import statements for third-party packages that are listed in package.json? I looked at the import/no-extraneous-dependencies rule but it doesn’t report any errors if the package cannot be resolved in the first place.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:10 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
ljharbcommented, Jan 25, 2020

Not in the js ecosystem it’s not; it’s also a bad practice regardless of how often it’s used.

I don’t think it makes any sense for any js tool to not assume npm install has been ran.

1reaction
sebastian-nowakcommented, Jan 25, 2020

Hmm, that’s not really true. In a large multi-language monorepo it’s common to have eslint installed just once (usually in /third_party/bin/eslint or similar) and some build system (such as Bazel or Buck) takes care of running it for various isolated packages. In such scenario, eslint isn’t installed globally but it’s not in the package’s node_modules either. It’s invalid to assume that node_modules will be present, it might be managed by a build system.

Read more comments on GitHub >

github_iconTop Results From Across the Web

import/no-unresolved requires installed node_modules #1627
It seems that import/no-unresolved will complain for valid import statements if node_modules isn't present or it's outdated.
Read more >
node.js - How to resolve "import/no-unresolved" in ESLint for ...
I was having this problem! Eslint cannot find the file's location because the path of the file is not fully defined, we must...
Read more >
eslint-plugin-import - npm
Ensure imports point to a file/module that can be resolved. ( no-unresolved ); Ensure named imports correspond to a named export in the ......
Read more >
no-restricted-imports - ESLint - Pluggable JavaScript Linter
Disallow specified modules when loaded by import ... For example, Node.js' fs module would not make sense in an environment that didn't have...
Read more >
rollup.js
Importing CommonJS · Publishing ES Modules ... npm install --global rollup ... import { createRequire } from 'node:module'; const require ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found