Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed to parse html #5767

Closed
7 tasks done
dedalusj opened this issue Nov 20, 2021 · 4 comments · Fixed by #5777
Closed
7 tasks done

Failed to parse html #5767

dedalusj opened this issue Nov 20, 2021 · 4 comments · Fixed by #5777

Comments

@dedalusj
Copy link

Describe the bug

Vite is failing to build due to a failure to parse the index.html file.

Reproduction

Create a new vanilla JS project with yarn create vite repro --template vanilla.

Replace the content of the index.html with the following:

<!DOCTYPE html>
<html lang="en">
<body>
<pre>
foo <=> baz;
</pre>
</body>
</html>

Try to build the project or run the dev server and the following error appears:

yarn run v1.22.10
warning package.json: No license field
$ vite build
vite v2.6.14 building for production...
✓ 0 modules transformed.
[vite:build-html] Unable to parse {"file":"repro/index.html","line":5,"column":6}
3  |  <body>
4  |  <pre>
5  |  foo <=> baz;
   |       ^
6  |  </pre>
7  |  </body>
file: repro/index.html
error during build:
Error: Unable to parse {"file":"repro/index.html","line":5,"column":6}
3  |  <body>
4  |  <pre>
5  |  foo <=> baz;
   |       ^
6  |  </pre>
7  |  </body>
    at traverseHtml (repro/node_modules/vite/dist/node/chunks/dep-e0fe87f8.js:21240:15)
    at async Object.transform (repro/node_modules/vite/dist/node/chunks/dep-e0fe87f8.js:21305:17)
    at async ModuleLoader.addModuleSource (repro/node_modules/rollup/dist/shared/rollup.js:22152:30)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

System Info

System:
    OS: macOS 12.0.1
    CPU: (8) arm64 Apple M1
    Memory: 232.83 MB / 16.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 17.0.1 - /opt/homebrew/bin/node
    Yarn: 1.22.10 - /opt/homebrew/bin/yarn
    npm: 8.1.0 - /opt/homebrew/bin/npm
  Browsers:
    Brave Browser: 89.1.21.77
    Chrome: 95.0.4638.69
    Firefox: 92.0.1
    Safari: 15.1
  npmPackages:
    vite: ^2.6.4 => 2.6.14

Used Package Manager

yarn

Logs

No response

Validations

@nurulhudaapon
Copy link
Contributor

< or > is not valid as child element in HTML. You need to escape these, see. Maybe the error message here can be improved.

@dedalusj
Copy link
Author

OK thanks. It was working in the browser and other similar tools so I assumed it would be OK. I'll escape the characters.

@nurulhudaapon
Copy link
Contributor

nurulhudaapon commented Nov 20, 2021

OK thanks. It was working in the browser and other similar tools so I assumed it would be OK. I'll escape the characters.

Yeah, browser tends to be forgiving on syntax error.

@Niputi
Copy link
Contributor

Niputi commented Nov 21, 2021

opening to possibly get better error message

@Niputi Niputi reopened this Nov 21, 2021
@Shinigami92 Shinigami92 linked a pull request Nov 21, 2021 that will close this issue
9 tasks
@github-actions github-actions bot locked and limited conversation to collaborators Jan 3, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants