Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Problems with importing libraries into typescript .ts files and cors errors

I am trying to build a fairly simple html canvas game in typescript, and for that I plan to use the Konva library. I can easily import it into my html file with <script src="... which should allow my program to run.
But since the typescript is in a separate folder I need to import it separately in order to not cause errors and to use suggestions in vscode. Using import requires that when connected to an html file it has type="module", and even though all of these files are in a folder together on my desktop, importing a js file that is a module causes CORS errors.

Is there any other way to do any of this? Every answer I seem to find requires creating a local http webserver, and that really seems like way to much effort for a coding an html canvas game.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

npm install konva

in vs code is one way

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading