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.

package.jon "exports" option

See original GitHub issue

node 12.18.0, 14.5.0

./node_modules/.bin/eslint --env-info Environment Info:

Node version: v14.5.0 npm version: v6.14.5 Local ESLint version: v7.4.0 (Currently used) Global ESLint version: Not found

What parser (default, Babel-ESLint, etc.) are you using? default

Please show your full configuration:

Configuration
module.exports = {
  env: {
    es2020: true,
    mocha: true,
  },
  extends: [
    'airbnb-base',
  ],
  parser: '@typescript-eslint/parser',
  plugins: [
    '@typescript-eslint',
  ],
  rules: {
    '@typescript-eslint/no-unused-vars': 'error',
    'import/no-extraneous-dependencies': ['error', { devDependencies: ['**/test.ts', 'src/common/test/**/*.ts'] }],
    'import/extensions': ['error', 'ignorePackages', {
      ts: 'never',
    }],
    'no-unused-vars': 'off',
  },
  settings: {
    'import/resolver': {
      node: {
        extensions: ['.ts'],
        paths: ['./src'],
      },
    },
  },
};

What did you do? Please include the actual source code causing the issue, as well as the command that you used to run ESLint.

in module A’s package.json use “exports”

{
  ...
  "exports": {
    "./": "./lib/"
  }
   ...
}

eslint --ext .js,.ts src/

What did you expect to happen? B’s package.json

{
  "dependencies": {
    "A": "A's url"
  }
}

when source code is

import bar from 'A/foo/bar';

From module B it runs well where bar.js is in “node_modules/A/lib/foo/bar” but eslint fail with “Unable to resolve path to module”

What actually happened? Please include the actual, raw output from ESLint. eslint failed

Are you willing to submit a pull request to fix this bug?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
heekyucommented, Jul 23, 2020

Thanks!

benmosher/eslint-plugin-import#1810

same issue is in eslint-plugin-import

please close this issue.

0reactions
mdjermanoviccommented, Jul 23, 2020

Closing since the problem isn’t related to ESLint core rules.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Modules: Packages | Node.js v19.3.0 Documentation
The "exports" provides a modern alternative to "main" allowing multiple entry points to be defined, conditional entry resolution support between environments, ...
Read more >
Package exports - webpack
The exports field in the package.json of a package allows to declare which module should be used when using module requests like import...
Read more >
Node.JS (New) Package.json Exports Field - Medium
The exports field (or “export map”) provides a way to expose your package modules for different environments and JavaScript flavors WHILE ...
Read more >
Exports in package.json - DEV Community ‍ ‍
Packages may export functions with the same names but doing different things. Let's look at 2 state managers: Reatom and Effector. Both of...
Read more >
New package.json `exports` field not working with TypeScript
The version 13.2 of Node.js allows ESM modules and a new package.json field, called exports , to select and rewrite exported files.
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