问题描述
我在预构建时遇到以下错误。
× ERROR Template execution Failed: Error: The XMLHttpRequest compatibility library was not found.
然而,preact dev 模式在相同的代码库中运行良好。我正在使用带有默认模板的 preact-cli。 有什么想法吗?
编辑:似乎是 firebase 导致的。不知道为什么。任何帮助表示赞赏。
Build [=================== ] 93% (14.4s) after chunk asset optimization[2021-01-25T20:12:57.501Z] @firebase/app:
Warning: This is a browser-targeted Firebase bundle but it appears it is being
run in a Node environment. If running in a Node environment,make sure you
are using the bundle specified by the "main" field in package.json.
If you are using Webpack,you can specify "main" as the first item in
"resolve.mainFields":
https://webpack.js.org/configuration/resolve/#resolvemainfields
解决方法
由 Preact 团队回答 - 使用 --no-prerender 标志构建,因为默认情况下 Preact 使用预渲染构建并且需要节点环境。