csdn/CSDN博文备份/VitePress项目部署cloudflarepage提示Node构建错误-147155315.md
2025-04-11 22:18:22 +08:00

1 line
3.0 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<p>提示的构建错误信息为:</p> <br><p></p> <br><pre><code>09:35:29.838 Error: Exit with error code: 1<br>09:35:29.839 at ChildProcess.<anonymous> (/snapshot/dist/run-build.js)<br>09:35:29.839 at Object.onceWrapper (node:events:652:26)<br>09:35:29.839 at ChildProcess.emit (node:events:537:28)<br>09:35:29.840 at ChildProcess._handle.onexit (node:internal/child_process:291:12)<br>09:35:29.847 Failed: build command exited with code: 1<br></code></pre> <br><p></p> <br><p class="img-center"><a href="https://cdn.isharkfly.com/com-isharkfly-www/discourse-uploads/original/3X/c/e/ceb4966d2e7f117f5195ec0439345f15c4f8084b.jpeg" rel="nofollow"><img alt="2025-04-11_09-42-11" height="500" src="https://i-blog.csdnimg.cn/img_convert/6c4cc91b89679c6fcaf5102689017659.jpeg" width="688" /></a></p> <br><p></p> <br><h3>原因和解决</h3> <br><p>提示上面错误信息的原因是 Yarn 的版本问题。</p> <br><p>在默认 NodeJS 的安装情况下Yarn 会安装 1.22 的版本。</p> <br><p>但在cloudflare 构建中,默认会使用 Yarn 3 的版本。</p> <br><p>在日志的最上部分,提示了安装 Yarn 的版本信息。</p> <br><p></p> <br><pre><code>09:35:26.187 No wrangler.toml file found. Continuing.<br>09:35:26.253 Detected the following tools from environment: yarn@3.6.3, nodejs@18.17.1<br></code></pre> <br><p></p> <br><p class="img-center"><a href="https://cdn.isharkfly.com/com-isharkfly-www/discourse-uploads/original/3X/e/b/ebb3ff09a08e0190af9f047a7efaa7a17a198d14.jpeg" rel="nofollow"><img alt="2025-04-11_09-43-24" height="328" src="https://i-blog.csdnimg.cn/img_convert/96f3a73119085238b52ec6315728eba6.jpeg" width="690" /></a></p> <br><p></p> <br><p>因此解决办法就是针对 VitePress 项目指定使用 yarn 的版本。</p> <br><p>运行命令来进行升级:</p> <br><p><code>yarn set version stable</code></p> <br><p>控制台输出:</p> <br><p></p> <br><pre><code>PS D:\WorkDir\iSharkFly\iSharkFly-Cn\docs-hn> yarn set version stable<br>➤ YN0000: Downloading https://repo.yarnpkg.com/4.9.1/packages/yarnpkg-cli/bin/yarn.js<br>➤ YN0000: Saving the new release in .yarn/releases/yarn-4.9.1.cjs<br>➤ YN0000: Done in 0s 195ms<br>PS D:\WorkDir\iSharkFly\iSharkFly-Cn\docs-hn> yarn -v<br>4.9.1<br>PS D:\WorkDir\iSharkFly\iSharkFly-Cn\docs-hn> <br></code></pre> <br><p></p> <br><p class="img-center"><a href="https://cdn.isharkfly.com/com-isharkfly-www/discourse-uploads/original/3X/b/3/b337f73e4e320ac2f77639fe295a26519f5ee7de.jpeg" rel="nofollow"><img alt="2025-04-11_09-50-41" height="264" src="https://i-blog.csdnimg.cn/img_convert/f6661ffa22d2c4faea2da5691322ebe5.jpeg" width="690" /></a></p> <br><p></p> <br><p>随后推送,重新部署即可。</p> <br><p></p> <br><p><a href="https://www.isharkfly.com/t/vitepress-cloudflare-page-node/17165" rel="nofollow" title="VitePress 项目部署 cloudflare page 提示 Node 构建错误 - DevOps - iSharkFly">VitePress 项目部署 cloudflare page 提示 Node 构建错误 - DevOps - iSharkFly</a></p>