Ghost was able to start, but errored during boot with: Cannot read properties of undefined (reading 'members')

Running in development mode

√ Checking system Node.js version - found v18.12.1
√ Checking current folder permissions
√ Validating config
√ Checking memory availability
√ Checking binary dependencies
× Starting Ghost: ghost-local
A GhostError occurred.

Message: Ghost was able to start, but errored during boot with: Cannot read properties of undefined (reading ‘members’)

Debug Information:
OS: Microsoft Windows 10 Home, v10.0.19045
Node Version: v18.12.1
Ghost Version: 5.79.4
Ghost-CLI Version: 1.25.3 below is my server.js

const express = require('express');
const GhostAdminAPI = require('@tryghost/admin-api');
require('dotenv').config();
const cors = require('cors');

const app = express();
app.use(cors());
app.use(express.json());

const port = 3001;

// Configure the Ghost Admin API client
const api = new GhostAdminAPI({
  url: process.env.GHOST_ADMIN_API_URL,
  key: process.env.GHOST_ADMIN_API_KEY,
  version: 'v3'
});

app.post('/api/subscribe', async (req, res) => {
  const { email } = req.body;

  try {
    // Use the Admin API client to add a member
    const response = await api.members.add({ email, subscribed: true });

    // If the request is successful, respond accordingly
    res.status(200).json({ message: 'Subscription successful', details: response });
  } catch (error) {
    // If there's an error, log it and respond with an error message
    console.error('Error making request to Ghost API:', error);
    res.status(500).json({ message: 'Internal server error', error: error.message });
  }
});

app.use((err, req, res, next) => {
  console.error('Unhandled error:', err.stack);
  res.status(500).json({ message: 'Internal server error', error: err.message });
});

app.listen(port, () => {
  console.log(`Server running on port ${port}`);
});

below is my ghostapi.js

const API_URL = 'http://127.0.0.1:2368/ghost/api/v3/content';
const API_KEY = 'mesecret the acutal value is here or was dont want to expose';

// Fetches all posts without applying a server-side filter for partial matches.
export const fetchPosts = async () => {
  try {
    const url = `${API_URL}/posts/?key=${API_KEY}&include=tags,authors&limit=all`;
    const response = await fetch(url);
    if (!response.ok) throw new Error('Network response was not ok');
    const { posts } = await response.json();
    return posts;
  } catch (error) {
    console.error("Error fetching posts:", error);
    return [];
  }
};




export const fetchSinglePost = async (slug) => {
  try {
    const response = await fetch(`${API_URL}/posts/slug/${slug}/?key=${API_KEY}&include=tags,authors`);
    if (!response.ok) throw new Error('Network response was not ok');
    const { posts } = await response.json();
    return posts[0]; // Assuming the API returns an array, take the first post.
  } catch (error) {
    console.error("Error fetching post:", error);
    return null;
  }
};

if need me to show any more files i can

You should not be editing any of those files manually. The only config file you’d want to be editing is config.production.json (or .development. for development servers).

If you’ve got changes in these files, it may make sense to reinstall and work through the installation directions carefully – .

BTW, while it’s possible to run Ghost on windows, you’re probably going to be happier running in WSL2 (Ubuntu 22). That works great for developing on a Windows computer while getting to use all the Linux dependencies. Highly recommended - the docs could be better about steering users that way.

so i should reinstall then how would that fix it

I was asking (perhaps unclearly) if you were modifying the files you pasted in. Can you confirm that you ran through the whole Ghost local install process without errors (here: How to install Ghost locally on Mac, PC or Linux and pages for Node, etc linked from it), and didn’t edit any files manually except maybe config.development.json?

It might be helpful to paste in your config.development.json file contents (inside </> so that the formatting doesn’t get messed up). I was confused because you were pasting in Ghost core files that shouldn’t be edited.

If it were me (and it was me, a couple years ago), and I knew what I knew now, I’d uninstall Node etc from Windows [yeah, I know you just installed it, sorry - I don’t write the docs], install WSL2 (Ubuntu 22 version), and do the install of Node from within the WSL2 container. Everything is better tested on Linux, and it avoids a show-stopper bug where theme assets don’t get built correctly in Windows. That’s my current setup for editing sites locally, and I deal with far less glitchy behavior since switching from working on Windows to working in WSL on Windows.

Tutorial:

from what im aware i only edited the config.developement.json and i was using the server.js with api in and used ghost api to try and add a members feature of some sort it say this here too

`

OK, so that’s a separate problem. And maybe one we can fix. Can you check that your Ghost folder contains content/themes ? And then in that folder there should be a symlink to the source directory, which lives over in current/content/themes

It’s weird - that link should have been automatically created during the install. And the members error sounds like maybe your database setup also failed.

I’d recommend that you delete the Ghost install directory and star over, honestly. I’m not sure what went wrong, but something did!

i went ahead and put it on uhh wsl so everything is running on wsl now and i aslo uploaded it to git and will commit regulary so if a issue occurrs i can use version control to revert back to previous state and i just re created the ghost instance and now its running just fine thanks for the help

but it works now thanks alot

Great, glad you’re up and running! :) Come on back when you have more questions! :)

I am having the same issue after I plugged in Stripe in test mode in a local install.

Message: Ghost was able to start, but errored during boot with: Cannot read properties of undefined (reading 'members')

Still hasn’t figure it out what I did wrong.

This is the log:

    at ChildProcess.<anonymous> (/Users/sergio/.nvm/versions/node/v18.18.2/lib/node_modules/ghost-cli/lib/utils/local-process.js:75:35)
    at ChildProcess.emit (node:events:517:28)
    at emit (node:internal/child_process:944:14)
    at process.processTicksAndRejections (node:internal/process/task_queues:83:21)```

This solution worked just fine: Cannot disconnect while there are members with active Stripe subscriptions - #6 by Hannah