Skip to main content

Install CLI

WP-Node provides a CLI to create tables and seed initial records in a WordPress-compatible database. This allows you to bootstrap a WP-Node app without installing WordPress.

Prerequisite

Make sure you have MySQL or MariaDB running. If you don’t, you can spin up a MariaDB instance using Docker:

docker network inspect wpnet >/dev/null 2>&1 || docker network create wpnet && \
docker run --name wpdb --network wpnet -p 33307:3306 \
-e MYSQL_ROOT_PASSWORD=example \
-e MYSQL_DATABASE=wordpress \
-e MYSQL_USER=wp \
-e MYSQL_PASSWORD=wp \
mariadb

To remove the database and clean up Docker:

docker rm -f wpdb && docker network rm wpnet

⚙️ Generate Config Files

Run the following command to create the required configuration files:

npx @rnaga/wp-node-cli -- config

You'll be prompted to fill in database details:

✔ Enter your database hostname: · localhost
✔ Enter your database port: · 33307
✔ Enter your database username: · wp
✔ Enter your database password: · **
✔ Enter your database name: · wordpress
✔ Is it a multi-site? · No
✔ Enter your static assets path: · public

🏗️ Run Install CLI

npx @rnaga/wp-node-cli -- install

You’ll be guided through site and user setup:

✔ Enter your site URL: · http://localhost
✔ What is the title of the blog? · WP-Node Install CLI Test
✔ What is the user email of the blog? · wp@example.com
✔ What is the user name of the blog? · wptest
✔ What is the user password? · ******
✔ Is the blog public? (y/N) · false
✔ Procceed? (y/N) · true
Creating databases...
Blog created successfully!
{
siteUrl: 'http://localhost',
blogTitle: 'WP-Node Install CLI Test',
userName: 'wptest',
userEmail: 'wp@example.com',
userId: 1
}

✅ Test Your Setup

After installation, you can start using other CLI commands, such as retrieving a post:

npx @rnaga/wp-node-cli -- post get 1 -F ID,post_title -Z table

┌────────────┬────────────────┐
│ (index) │ Values │
├────────────┼────────────────┤
│ ID │ 1 │
│ post_title │ 'Hello world!' │
└────────────┴────────────────┘