这里写自定义目录标题
cloudflare 构建hexo程序失败
最近在使用hexo搭建博客的时候,准备托管在cloudflare上面,本地部署没问题(本地环境为:macOS 14.4.1,node:20.5.0,npm: 8.6.0 ),push 到GitHub上并在cloudflare上配置Pages并连接git,配置如下:
多次检查配置都没问题,运行环境也和本地一样
00:22:33.626 Using v2 root directory strategy
00:22:33.650 Success: Finished cloning repository files
00:22:35.475 Checking for configuration in a wrangler.toml configuration file (BETA)
00:22:35.476
00:22:35.616 No wrangler.toml file found. Continuing.
00:22:35.790 Detected the following tools from environment: nodejs@20.5.0, npm@9.6.7, yarn@3.6.3
00:22:35.791 Installing nodejs 20.5.0
00:22:36.732 Trying to update node-build... ok
00:22:36.941 Downloading node-v20.5.0-linux-x64.tar.gz...
00:22:36.941 -> https://nodejs.org/dist/v20.5.0/node-v20.5.0-linux-x64.tar.gz
00:22:38.560 Installing node-v20.5.0-linux-x64...
00:22:38.958 Installed node-v20.5.0-linux-x64 to /opt/buildhome/.asdf/installs/nodejs/20.5.0
00:22:38.958
00:22:40.405 Preparing yarn@3.6.3 for immediate activation...
00:22:40.853 Installing project dependencies: yarn
到构建这一步报错了,好家伙
00:22:41.433 ➤ YN0070: Migrating from Yarn 1; automatically enabling the compatibility node-modules linker 👍
00:22:41.433
00:22:41.462 ➤ YN0000: ┌ Resolution step
00:22:42.085 ➤ YN0061: │ domexception@npm:4.0.0 is deprecated: Use your platform's native DOMException instead
00:22:42.093 ➤ YN0061: │ abab@npm:2.0.6 is deprecated: Use your platform's native atob() and btoa() methods instead
00:22:42.213 ➤ YN0061: │ cuid@npm:2.1.8 is deprecated: Cuid and other k-sortable and non-cryptographic ids (Ulid, ObjectId, KSUID, all UUIDs) are all insecure. Use @paralleldrive/cuid2 instead.
00:22:42.423 ➤ YN0032: │ fsevents@npm:2.3.3: Implicit dependencies on node-gyp are discouraged
00:22:42.838 ➤ YN0000: └ Completed in 1s 376ms
00:22:42.858 ➤ YN0000: ┌ Post-resolution validation
00:22:42.858 ➤ YN0028: │ The lockfile would have been modified by this install, which is explicitly forbidden.
00:22:42.858 ➤ YN0000: └ Completed
00:22:42.858 ➤ YN0000: Failed with errors in 1s 397ms
00:22:42.890 Error: Exit with error code: 1
00:22:42.890 at ChildProcess.<anonymous> (/snapshot/dist/run-build.js)
00:22:42.891 at Object.onceWrapper (node:events:652:26)
00:22:42.891 at ChildProcess.emit (node:events:537:28)
00:22:42.891 at ChildProcess._handle.onexit (node:internal/child_process:291:12)
00:22:42.902 Failed: build command exited with code: 1
00:22:43.827 Failed: error occurred while running build command
最后反复试了很多次,找到原因了,问题在这一行
00:22:33.626 Using v2 root directory strategy
只需要把配置生产构建系统的版本从2选到1就可以,默认是选择的2 具体构建系统版本1和2区别请点链接:👉language-support-and-tools
在部署一次就发现部署成功了