Hexo has a bit of a refactor from version 2.6 onwards to make it a bit more flexible with regard to the node modules it uses. So when you create a new Hexo project you have to add some module to that project before you can generate your site. This is an easy step as its managed by the Node package manager (npm).
There are more details about migration steps on the Hexo Github project.
Here are the essential details and options for upgrading to Hexo 2.6 onwards.
You can easily check the version of Hexo you are using with the following command:
This should give you output similar to:
Upgrading Hexo is as easy as installing Hexo in the first place. Simply use node package manager to install the latest version
npm install -g hexo
The above command uses the global option, -g, so anyone can run hexo. If you have installed Hexo in a directory not owned by your operating system account (eg.
/opt) then you should use
sudoin front of this command, ie.
sudo npm install -g hexo
As before, you can check you are running the latest version of hexo using the command:
This time you should have a newer version:
As I am only upgrading Hexo to a new vesion, only it has a new version. The other components are all the same version.
When you create a new Hexo project with the command
hexo init, the names of the extra node modules are written to the
package.json file. So all that is needed is to run the node package manager
hexo init my-project cd my-project npm install
If you have a project that was created before Hexo version 2.6, you need to reinitialise the Hexo project. To do this, change into the hexo directory and run the command:
cd my-existing-project hexo init
hexo init command updates the
package.json file with the names of the required modules. Then as with a new project you run the node package manager to fetch and install the modules:
If you want to control over what is being changed in your Hexo project nodejs packages, you can add each package seperately. Here we are using the
--save to ensure the package is added to the
packages.json file for the Hexo project.
npm install hexo-renderer-ejs --save
If all goes wrong then try uninstalling hexo and install again (the classic IT approach).
npm remove hexo npm install hexo -g
Then check the version again to see if the new hexo will run.
This work is licensed under a Creative Commons Attribution 4.0 ShareAlike License, including custom images & stylesheets. Permissions beyond the scope of this license may be available at @jr0cket