1
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 5 years have passed since last update.

webpack+typescriptで、jsonインポート部分のエイリアスを定義しているのに、Cannot find moduleエラー

Posted at

webpackでエイリアスで定義しているのに、Cannot find moduleエラーが出て、ちょっと悩みました。

webpack.config.js


alias: {
  '@': path.join(__dirname, './src/javascript')
}

i18n.ts(抜粋)


import i18next from 'i18next'
import { initReactI18next } from 'react-i18next'

import localeJson from '@/app/config/locale.json'

エラーメッセージ

ERROR in src/javascript/app/config/i18n.ts(4,24)
      TS2307: Cannot find module '@/app/config/locale.json'

原因

tsconfig.jsonの定義とwebpackのaliasの定義が矛盾してました。

"paths": {
  "@/*": ["src/javascript/app/*"]
}

久しぶりに触ったリポジトリだったので、定義してたのすっかり忘れてました。

1
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
1
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?