使用Hexo搭建GitHub博客时执行npm install与hexo init遇问题求助
Hey there, let's work through this problem together. From your output, it looks like the hexo init command got stuck while cloning the landscape theme submodule, which is probably why your npm install is failing afterward. Here's a step-by-step fix:
Step 1: Clean Up the Incomplete Directory
First, delete the half-created E:\Blog folder entirely. This ensures we start with a fresh slate—no leftover partial files messing things up.
Step 2: Manually Initialize Hexo Project (Avoid Submodule Stalls)
Instead of relying on hexo init (which can choke on submodules due to network issues), let's build the project manually:
- Open your terminal and run these commands one by one:
This pulls the base Hexo starter code first, then explicitly fetches the landscape theme submodule, which is more reliable than the one-stepmkdir E:\Blog && cd E:\Blog git init git pull https://github.com/hexojs/hexo-starter.git git submodule update --init --recursivehexo initwhen there's network instability.
Step 3: Resolve Npm Install Errors
Now that we have a complete project structure, let's fix the npm install issue:
- Stay in the
E:\Blogdirectory and run:npm cache clean --force npm install - If you're still getting errors (often due to network restrictions), try using a domestic npm mirror:
npm install --registry=https://registry.npmmirror.com
Step 4: Verify the Fix
To make sure everything works, test the local server:
hexo generate hexo server
Then open http://localhost:4000 in your browser—you should see the default Hexo page if all went well.
Extra Checks If Problems Persist
- Check Node.js Version: Hexo requires Node.js 14.17 or higher. Run
node -vto verify, and upgrade if needed. - Avoid Non-ASCII Paths: Make sure your project path (
E:\Blog) has no Chinese characters or special symbols—Hexo can have compatibility issues with these.
内容的提问来源于stack exchange,提问作者bricker

