vite build fails with CRLF endings in index.html: eof-in-element-that-can-contain-only-text
See original GitHub issueDescribe the bug
I have set git config --global core.autocrlf true
so that on Linux my index.html has LF line endings and on Windows it has CRLF endings.
With LF line endings, vite build
works perfectly, but on Windows with CRLF, I get the following error message:
vite v3.1.8 building for production...
✓ 0 modules transformed.
[vite:build-html] Unable to parse HTML; parse5 error code eof-in-element-that-can-contain-only-text
at {"file":"H:/projekte/graph2/index.html","line":105,"column":1}
file: H:/projekte/graph2/index.html
error during build:
Error: Unable to parse HTML; parse5 error code eof-in-element-that-can-contain-only-text
at {"file":"H:/projekte/graph2/index.html","line":105,"column":1}
at handleParseError (file:///H:/projekte/graph2/node_modules/vite/dist/node/chunks/dep-4da11a5e.js:43393:11)
at Parser.onParseError (file:///H:/projekte/graph2/node_modules/vite/dist/node/chunks/dep-4da11a5e.js:43320:13)
at Parser._err (file:///H:/projekte/graph2/node_modules/vite/dist/node/chunks/dep-19c40c50.js:4942:14)
at eofInText (file:///H:/projekte/graph2/node_modules/vite/dist/node/chunks/dep-19c40c50.js:6977:7)
at Parser.onEof (file:///H:/projekte/graph2/node_modules/vite/dist/node/chunks/dep-19c40c50.js:5731:17)
at Tokenizer._emitEOFToken (file:///H:/projekte/graph2/node_modules/vite/dist/node/chunks/dep-19c40c50.js:1403:22)
at Tokenizer._stateRawtext (file:///H:/projekte/graph2/node_modules/vite/dist/node/chunks/dep-19c40c50.js:1903:22)
at Tokenizer._callState (file:///H:/projekte/graph2/node_modules/vite/dist/node/chunks/dep-19c40c50.js:1522:22)
at Tokenizer._runParsingLoop (file:///H:/projekte/graph2/node_modules/vite/dist/node/chunks/dep-19c40c50.js:1179:22)
at Tokenizer.write (file:///H:/projekte/graph2/node_modules/vite/dist/node/chunks/dep-19c40c50.js:1204:14)
The error goes away when I convert the file from CRLF to LF in Notepad++.
Reproduction
git@github.com:snikproject/graph.git
Steps to reproduce
git clone git@github.com:snikproject/graph.git
cd graph
git checkout f9a450f966ac44c6f0fa1cfd7a5ba3d89fa6d32d
npm install
vite build
System Info
System:
OS: Windows 10 10.0.19044
CPU: (6) ia32 Intel(R) Core(TM) i5-9600 CPU @ 3.10GHz
Memory: 10.54 GB / 15.79 GB
Binaries:
Node: 19.0.0 - H:\opt\node\node.EXE
npm: 8.19.2 - H:\opt\node\npm.CMD
Browsers:
Edge: Spartan (44.19041.1266.0), Chromium (106.0.1370.47)
Internet Explorer: 11.0.19041.1566
Used Package Manager
npm
Logs
Click to expand!
vite:config bundled config file loaded in 350.49ms +0ms
vite:esbuild init tsconfck (root: H:/projekte/graph) +0ms
vite:esbuild init tsconfck (root: H:/projekte/graph) +5ms
vite:esbuild init tsconfck (root: H:/projekte/graph) +4ms
vite:esbuild init tsconfck (root: H:/projekte/graph) +3ms
vite:esbuild init tsconfck end +82ms
vite:esbuild init tsconfck end +1ms
vite:esbuild init tsconfck end +0ms
vite:esbuild init tsconfck end +0ms
vite:config using resolved config: {
vite:config base: './',
vite:config sourcemap: true,
vite:config build: {
vite:config target: [ 'es2020', 'edge88', 'firefox78', 'chrome87', 'safari13' ],
vite:config polyfillModulePreload: true,
vite:config outDir: 'dist',
vite:config assetsDir: 'assets',
vite:config assetsInlineLimit: 4096,
vite:config cssCodeSplit: true,
vite:config cssTarget: [ 'es2020', 'edge88', 'firefox78', 'chrome87', 'safari13' ],
vite:config sourcemap: false,
vite:config rollupOptions: { input: [Object], output: [Object] },
vite:config minify: 'esbuild',
vite:config terserOptions: {},
vite:config write: true,
vite:config emptyOutDir: null,
vite:config manifest: false,
vite:config lib: false,
vite:config ssr: false,
vite:config ssrManifest: false,
vite:config reportCompressedSize: true,
vite:config chunkSizeWarningLimit: 500,
vite:config watch: null,
vite:config commonjsOptions: { include: [Array], extensions: [Array] },
vite:config dynamicImportVarsOptions: { warnOnError: true, exclude: [Array] }
vite:config },
vite:config test: { globals: true },
vite:config optimizeDeps: {
vite:config disabled: 'build',
vite:config force: undefined,
vite:config esbuildOptions: { preserveSymlinks: undefined }
vite:config },
vite:config configFile: 'H:/projekte/graph/vite.config.js',
vite:config configFileDependencies: [ 'H:/projekte/graph/vite.config.js' ],
vite:config inlineConfig: {
vite:config root: undefined,
vite:config base: undefined,
vite:config mode: undefined,
vite:config configFile: undefined,
vite:config logLevel: undefined,
vite:config clearScreen: undefined,
vite:config optimizeDeps: { force: undefined },
vite:config build: {}
vite:config },
vite:config root: 'H:/projekte/graph',
vite:config resolve: { alias: [ [Object], [Object] ] },
vite:config publicDir: 'H:\\projekte\\graph\\public',
vite:config cacheDir: 'H:\\projekte\\graph\\node_modules\\.vite',
vite:config command: 'build',
vite:config mode: 'production',
vite:config ssr: {
vite:config format: 'esm',
vite:config target: 'node',
vite:config optimizeDeps: { disabled: true, esbuildOptions: [Object] }
vite:config },
vite:config isWorker: false,
vite:config mainConfig: null,
vite:config isProduction: true,
vite:config plugins: [
vite:config 'vite:build-metadata',
vite:config 'vite:pre-alias',
vite:config 'alias',
vite:config 'vite:modulepreload-polyfill',
vite:config 'vite:resolve',
vite:config 'vite:html-inline-proxy',
vite:config 'vite:css',
vite:config 'vite:esbuild',
vite:config 'vite:json',
vite:config 'vite:wasm-helper',
vite:config 'vite:worker',
vite:config 'vite:asset',
vite:config 'vite:wasm-fallback',
vite:config 'vite:define',
vite:config 'vite:css-post',
vite:config 'vite:build-html',
vite:config 'vite:worker-import-meta-url',
vite:config 'vite:force-systemjs-wrap-complete',
vite:config 'vite:watch-package-data',
vite:config 'commonjs',
vite:config 'vite:data-uri',
vite:config 'vite:asset-import-meta-url',
vite:config 'vite:dynamic-import-vars',
vite:config 'vite:import-glob',
vite:config 'vite:build-import-analysis',
vite:config 'vite:esbuild-transpile',
vite:config 'vite:terser',
vite:config 'vite:reporter',
vite:config 'vite:load-fallback'
vite:config ],
vite:config server: {
vite:config preTransformRequests: true,
vite:config middlewareMode: false,
vite:config fs: { strict: true, allow: [Array], deny: [Array] }
vite:config },
vite:config preview: {
vite:config port: undefined,
vite:config strictPort: undefined,
vite:config host: undefined,
vite:config https: undefined,
vite:config open: undefined,
vite:config proxy: undefined,
vite:config cors: undefined,
vite:config headers: undefined
vite:config },
vite:config env: {
vite:config VITE_GIT_BRANCH_NAME: 'master',
vite:config VITE_GIT_COMMIT_DATE: '2022-10-10T13:20:11+02:00',
vite:config VITE_GIT_COMMIT_HASH: 'f9a450f966ac44c6f0fa1cfd7a5ba3d89fa6d32d',
vite:config VITE_GIT_LAST_COMMIT_MESSAGE: 'Only layout nodes, not all elements.',
vite:config BASE_URL: './',
vite:config MODE: 'production',
vite:config DEV: false,
vite:config PROD: true
vite:config },
vite:config assetsInclude: [Function: assetsInclude],
vite:config logger: {
vite:config hasWarned: false,
vite:config info: [Function: info],
vite:config warn: [Function: warn],
vite:config warnOnce: [Function: warnOnce],
vite:config error: [Function: error],
vite:config clearScreen: [Function: clearScreen],
vite:config hasErrorLogged: [Function: hasErrorLogged]
vite:config },
vite:config packageCache: Map(0) { set: [Function (anonymous)] },
vite:config createResolver: [Function: createResolver],
vite:config worker: {
vite:config format: 'iife',
vite:config plugins: [
vite:config 'vite:build-metadata',
vite:config 'vite:pre-alias',
vite:config 'alias',
vite:config 'vite:modulepreload-polyfill',
vite:config 'vite:resolve',
vite:config 'vite:html-inline-proxy',
vite:config 'vite:css',
vite:config 'vite:esbuild',
vite:config 'vite:json',
vite:config 'vite:wasm-helper',
vite:config 'vite:worker',
vite:config 'vite:asset',
vite:config 'vite:wasm-fallback',
vite:config 'vite:define',
vite:config 'vite:css-post',
vite:config 'vite:build-html',
vite:config 'vite:worker-import-meta-url',
vite:config 'vite:force-systemjs-wrap-complete',
vite:config 'vite:watch-package-data',
vite:config 'commonjs',
vite:config 'vite:data-uri',
vite:config 'vite:asset-import-meta-url',
vite:config 'vite:dynamic-import-vars',
vite:config 'vite:import-glob',
vite:config 'vite:build-import-analysis',
vite:config 'vite:esbuild-transpile',
vite:config 'vite:terser',
vite:config 'vite:reporter',
vite:config 'vite:load-fallback'
vite:config ],
vite:config rollupOptions: {},
vite:config getSortedPlugins: [Function: getSortedPlugins],
vite:config getSortedPluginHooks: [Function: getSortedPluginHooks]
vite:config },
vite:config appType: 'spa',
vite:config experimental: { importGlobRestoreExtension: false, hmrPartialAccept: false },
vite:config getSortedPlugins: [Function: getSortedPlugins],
vite:config getSortedPluginHooks: [Function: getSortedPluginHooks]
vite:config } +903ms
vite v3.1.8 building for production...
✓ 0 modules transformed.
[vite:build-html] Unable to parse HTML; parse5 error code eof-in-element-that-can-contain-only-text
at {"file":"H:/projekte/graph/index.html","line":104,"column":8}
file: H:/projekte/graph/index.html
error during build:
Error: Unable to parse HTML; parse5 error code eof-in-element-that-can-contain-only-text
at {"file":"H:/projekte/graph/index.html","line":104,"column":8}
at handleParseError (file:///H:/projekte/graph/node_modules/vite/dist/node/chunks/dep-4da11a5e.js:43393:11)
at Parser.onParseError (file:///H:/projekte/graph/node_modules/vite/dist/node/chunks/dep-4da11a5e.js:43320:13)
at Parser._err (file:///H:/projekte/graph/node_modules/vite/dist/node/chunks/dep-19c40c50.js:4942:14)
at eofInText (file:///H:/projekte/graph/node_modules/vite/dist/node/chunks/dep-19c40c50.js:6977:7)
at Parser.onEof (file:///H:/projekte/graph/node_modules/vite/dist/node/chunks/dep-19c40c50.js:5731:17)
at Tokenizer._emitEOFToken (file:///H:/projekte/graph/node_modules/vite/dist/node/chunks/dep-19c40c50.js:1403:22)
at Tokenizer._stateRawtext (file:///H:/projekte/graph/node_modules/vite/dist/node/chunks/dep-19c40c50.js:1903:22)
at Tokenizer._callState (file:///H:/projekte/graph/node_modules/vite/dist/node/chunks/dep-19c40c50.js:1522:22)
at Tokenizer._runParsingLoop (file:///H:/projekte/graph/node_modules/vite/dist/node/chunks/dep-19c40c50.js:1179:22)
at Tokenizer.write (file:///H:/projekte/graph/node_modules/vite/dist/node/chunks/dep-19c40c50.js:1204:14)
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn’t already an issue that reports the same bug to avoid creating a duplicate.
- Make sure this is a Vite issue and not a framework-specific issue. For example, if it’s a Vue SFC related bug, it should likely be reported to vuejs/core instead.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- The provided reproduction is a minimal reproducible example of the bug.
Issue Analytics
- State:
- Created a year ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
[vite:build-html] Unable to parse html in build step · Issue #4067
my index.html is perfectly valid but my other dozen HTML files that we import as strings are not all valid (in syntax). [vite: ......
Read more >LF will be replaced by CRLF in git - What is that and is it ...
Gives the following warnings for many files: The file will have its original line endings in your working directory. warning: LF will be...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Here is the reproduction repository: https://github.com/KonradHoeffner/vite-bug-crlf
Closing as it’s fixed in upstream. It will be fixed when the next version of
parse5
is released.