Skip to content

Missing 'main' field in package.json #35

@MarttiR

Description

@MarttiR

Describe the bug

eslint-plugin-import falsely reports a module resolution error when trying to import/require this module, because there is no 'main' field in package.json.

import-js/eslint-plugin-import#2132

Node.js docs suggest using the 'main' field for compatibility with older versions of build tools.

For projects using an older version of Node.js or a related build tool, compatibility can be achieved by including the "main" field alongside "exports" pointing to the same module

However, this happens even with the newest versions of eslint and its import plugin.

There is a workaround but it requires a change to the eslint config, which is not great:

    settings: {
      'import/resolver': [
        path.resolve(__dirname, 'eslint-custom-resolver.cjs'),
        'node',
      ],
    },

Steps to reproduce

Try to import the package in a project that uses eslint with eslint-plugin-import.

Expected behavior

Importing/requiring this package does not cause issues with other tooling.

Screenshots and recordings

No response

Logs

error  Unable to resolve path to module 'svg-chunk-webpack-plugin'  import/no-unresolved

System Info

Node version: v22.14.0

npm packages:
- eslint
- eslint-plugin-import

Severity

Annoyance

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingwontfixThis will not be worked on

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions