In TypeScript, there is a compiler option known as baseUrl
that allows you to use non-relative paths, like:
import Command from "util/Command"
as opposed to:
import Command from "../../../util/Command"
While this works fine during compilation, TypeScript retains the non-relative paths and generates:
const Command_1 = require("util/Command")
When the application is run with
$ electron .
this may lead to a 'Cannot find module 'util/Command' error, as it does not recognize the baseUrl
setting.
I am aware that this issue can be resolved by utilizing Webpack's resolve.alias
, but since I am not utilizing Webpack in this project, I prefer not to introduce it just for this purpose.
I have already attempted the following suggestions without success: