0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Cannot find module ... or its corresponding type declarations

Posted at

問題

以下のようにimportしたら、

import app from '@/basicAuth'

以下のエラーが出ました。

TS2307: Cannot find module '@/basicAuth' or its corresponding type declarations.

webpackには、alias定義しているのに、何故だろうと思ってました。

原因

tsconfig.jsonにaliasを定義していないからです。

対応方法

以下のようにbaseUrlpathsを定義すれば解決します。

  "compilerOptions": {
    〜〜〜〜 省略 〜〜〜〜
    "baseUrl": ".",
    "paths": {
      "@/*": ["src/*"]
    }
   〜〜〜〜 省略 〜〜〜〜
  }
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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?