Fixing "Uncaught ReferenceError: define is not defined" in Ghost Admin
Today, I encountered a frustrating issue: I couldn’t access the admin panel (dashboard) of my Ghost blog. The page was stuck on a blank white screen with no content loading. 😓
Curious, I opened the Firefox browser console to investigate. There, I found this JavaScript error:
Uncaught ReferenceError: define is not defined
After some digging, I discovered it was related to my NGINX cache setup. Here's how I fixed it.
My Environment
- OS: Ubuntu 20.04
- Ghost: Version 5 (running inside Docker)
- Web Server: NGINX 1.22 as a reverse proxy
The Fix: Adjust NGINX Cache Directory Permissions
The issue stemmed from improper ownership of the NGINX cache directory. Ghost’s admin panel was trying to serve cached JavaScript files, but NGINX didn’t have the right permissions to read/write them properly.
Step 1: Check the Ownership of /var/cache/nginx
Run:
ls -lah /var/cache/
Example output:
drwxr-xr-x 7 root root 4.0K Jun 19 17:11 nginx
As you can see, the nginx
directory was owned by root
. That’s the problem.
Step 2: Identify NGINX's User
Open your NGINX config file:
cat /etc/nginx/nginx.conf
Look for a line like:
user www-data;
In my case, NGINX runs as www-data
.
Step 3: Fix the Ownership
Change the ownership of the cache directory so NGINX can properly access it:
sudo chown -R www-data:www-data /var/cache/nginx
Done! 🎉
After updating the ownership, I restarted NGINX and refreshed the Ghost admin page. Everything loaded perfectly—no more blank screen or console errors.
If you're running Ghost inside Docker with NGINX as a reverse proxy and hit this error, this fix might save you a lot of time.
Member discussion