LoginSignup
0
0

More than 3 years have passed since last update.

GithubActions を作って動かそうとしたら "ReferenceError: define is not defined" と言われた

Posted at

やりたかったこと

typescript で 書いた GitHub Actions のコードをトランスパイルして実行する。
しかし、GitHub Actions で呼び出した際にエラーが発生する。

エラー文

エラーが発生した箇所
https://github.com/tkt-actions/add-issue-links/runs/925347571?check_suite_focus=true

Run tkt-actions/add-issue-links@v1.0.2
/home/runner/work/_actions/tkt-actions/add-issue-links/v1.0.2/lib/main.js:1
define("domain/error/BaseError", ["require", "exports"], function (require, exports) {
^

ReferenceError: define is not defined
    at Object.<anonymous> (/home/runner/work/_actions/tkt-actions/add-issue-links/v1.0.2/lib/main.js:1:1)
    at Module._compile (internal/modules/cjs/loader.js:959:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:995:10)
    at Module.load (internal/modules/cjs/loader.js:815:32)
    at Function.Module._load (internal/modules/cjs/loader.js:727:14)
    at Function.Module.runMain (internal/modules/cjs/loader.js:1047:10)
    at internal/main/run_main_module.js:17:11

どうやって直したか

差分全体: https://github.com/tkt-actions/add-issue-links/compare/v1.0.1...v1.0.5

絶対パスで指定していた import を相対パスで書き直した。(tsc は絶対パスの解決を行ってくれない)
(ここがエラー文の原因なのかはいまいちあやしい)

過程

ReferenceError: define is not defined の解決

差分全体: https://github.com/tkt-actions/add-issue-links/compare/v1.0.2...v1.0.4

tsconfig でビルドのターゲットを変更することで、ReferenceError: define is not defined は解決したが、新たに MODULE_NOT_FOUND のエラーに遭遇した。

エラー: https://github.com/tkt-actions/add-issue-links/runs/925458465?check_suite_focus=true

tsconfig.json

     "strict": true,
     "noImplicitAny": true,
     "strictNullChecks": true,
-    "target": "es2019",
+    "target": "es6",
     "sourceMap": true,
     "outDir": "./lib",
     "baseUrl": "./",

MODULE_NOT_FOUND の解決

差分全体: https://github.com/tkt-actions/add-issue-links/compare/v1.0.4...v1.0.5

絶対パスで指定していた import を相対パスで書き直した。
すると、 target の指定を戻しても、動くようになった。

まとめ

ビルドは、よーわからん

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