0

I have a simple HTML file with a script src as index.ts.

index.html

<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script src="./src/index.ts"></script>
</body>

</html>

index.js

console.log("Hello!!!")

I wish to simply run this HTML file.

I am following a tutorial series that gives instructions on how to install Parcel, and run it with that.

However, I have been encountering issue after issue with Parcel... I have looked through the tutorial Q&A and have tried every solution to try and get parcel working. Each solution just ends up causing another issue!

How can I get this to run? Webpack? If so, how do I configure Webpack for this? (Never used Webpack)

Grand
  • 175
  • 1
  • 12
  • 1
    What's your issue with Parcel? – Joris Jun 19 '21 at 17:52
  • @Joris Literally issue after issue after issue... I couldn't in stall it with npm first of all, so I had to install Yarn. Then, when I try to run the parcel command within the project, it throws an error Build failed. @parcel/transformer-babel: Config result is not hashable because it contains non-serializable objects. Please use config.setResultHash to set the hash manually. And if I install Parcel locally to the project, it gives the error @parcel/core: Invalid Parcel Config I'm following all the instructions. I just want to get it working without having to do config! – Grand Jun 19 '21 at 21:18

2 Answers2

0

I wish to simply run this HTML file.

Your browser does not understand TypeScript. You need to transpile it. However when you serve this html file with parcel, it does the compilation on the fly.

What will work: So parcel index.html and visit http://localhost:1234/ What will not work: Opening the html file by itself e.g. open index.html

More

See Parcel documentation : https://parceljs.org/getting_started.html

basarat
  • 261,912
  • 58
  • 460
  • 511
0

There seems to be a typo in your script tag.

Try changing <script src="./src/index.ts"></script> to <script src="./src/index.js"></script>

Big Dumb
  • 120
  • 1
  • 7