LoginSignup
0
0

More than 1 year has passed since last update.

[Vue,Typescript] Uncaught ReferenceError: exports is not definedを解決する

Last updated at Posted at 2022-10-21

やりたいこと

Vue(Javascript)からTypeScriptに変更したい。

エラー内容

Uncaught ReferenceError: exports is not defined
at ./resources/js/store/auth.ts (app.js:2431:1)
at **webpack_require** (app.js:115736:42)
at ./resources/js/store/index.ts (app.js:2464:30)
at **webpack_require** (app.js:115736:42)
at ./resources/js/router.ts (app.js:2252:31)
at **webpack_require** (app.js:115736:42)
at ./resources/js/app.ts (app.js:2141:32)
at **webpack_require** (app.js:115736:42)
at app.js:115901:64
at **webpack_require**.O (app.js:115773:23)

原因

tsconfig.ymlで"module": "commonjs”になっていたため。

CommonJSではrequire/exportsを使い、ES modulesではimport/exportを使うようです。

そのため、今回はES modulesのexportを使っていたため、exportsが見つからず、モジュールを呼び出すことができませんでしたというエラーが出てしまっていたわけです。

解決策

tsconfig.ymlの"module": "commonjs”を削除する

調査

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