Thank you for reaching out to us on Microsoft Q&A forum.
The error message you are encountering suggests that Snowpack is interpreting your HTML file as a fragment due to the absence of the <!DOCTYPE html> declaration at the beginning. To resolve this issue, ensure that your index.html file includes the <!DOCTYPE html> declaration at the very start.
To fix this issue, make sure your index.html
file starts with the <!DOCTYPE html>
declaration, like this:
<!DOCTYPE html>
<html lang="en">
<head>
<title>Recipes</title>
</head>
<body>
<div id="app"></div>
<script type="module" src="/dist/index.js"></script>
</body>
</html>
Steps to Resolve the Issue
1.Open the index.html
file in your public
folder and ensure the first line
is <!DOCTYPE html>
.
2.Make sure that index.html
is in the public folder and index.jsx
is in the src folder.
3.Make sure your package.json
file includes the correct scripts for starting Snowpack, which should look something like this:
"scripts": {
"start": "snowpack dev",
"build": "snowpack build"
}
4.To start the development server, open the integrated terminal in Visual Studio Code by selecting View > Terminal or pressing Ctrl + \
(on Mac, `Cmd + \`
), and run the command npm start
.
5.Manually open your browser and navigate to http://localhost:8080 if it does not open automatically.
If you continue to face issues, please let us know in the comments. We are here to help.
If you find this information helpful, please acknowledge by clicking the "Upvote" buttons on the post.