LoginSignup
0
0

More than 1 year has passed since last update.

Unable to resolve path to module 'xxx'の対処法(pacakge.jsonでexportsが設定されている場合)

Posted at

問題

ESLintにかけると次のようなメッセージが出る。xxxの部分はnode_modules以下のパッケージ。

Unable to resolve path to module 'xxx'  import/no-unresolved

このエラーが出る状況は様々なようですが、今回の場合はeslint-plugin-importpackage.jsonexportsを考慮してくれないことが原因でした。

上のissueでワークアラウンドがいくつか提案されていますが、以下ではeslint-import-resolver-typescriptを使った方法を紹介します。

解決策

$ npm i -D eslint-import-resolver-typescript    
.eslintrc.json
{
    // その他の設定
    "settings": {
        "import/resolver": {
            "typescript": {}
        }
    }
}

最小限の設定を書いただけなので、場合によっては追加の記述が必要かもしれません。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0