5

Electron now supports typescript. But by running the example published in:

Electron official blog.

I always get the following error:

enter image description here

Should I have done something else?

3
  • When error pop up appears, do Ctrl+C and copy then paste error instead of screenshot Commented Sep 10, 2017 at 6:43
  • can you show the package.json file Commented Jul 18, 2019 at 10:20
  • cannot see your codes to help you detect the issues, but mine worked. github.com/tim-hub/clean-hosts Commented Jul 18, 2019 at 10:21

2 Answers 2

2

The support that they have for Typescript is that they provide definition files. At runtime you still have to run Javascript. Compile the Typescript to Javascript and then use the resulting .js file as your entry point.

Sign up to request clarification or add additional context in comments.

Comments

1

Install ts-node and typescript package to your project and then add parameter -r ts-node/register when running electron

npm install ts-node
npm install typescript

electron -r ts-node/register .

and add require('ts-node/register') in your html file

<script>
require('ts-node/register')
</script>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.