Cannot import MySQL in frontend app (to access a MySQL database) from some pages

Topic summary

A developer is trying to set up a remote MySQL database (Amazon RDS) to store sensitive Shopify app credentials including API keys, secrets, and GraphQL tokens.

Current Status:

  • MySQL import and database access works successfully from web/index.js
  • Import fails in frontend page files located in web/frontend/pages directory

Error Details:

  • TypeError occurs when attempting to import MySQL: “Cannot read properties of undefined (reading ‘NODE_DEBUG’)”
  • Error appears in Chrome console when the import statement import mysql from 'mysql2'; is present

Key Issue:
The MySQL module cannot be imported from frontend pages despite working in backend files, suggesting a client-side/server-side code execution conflict. The developer is seeking help understanding why this limitation exists.

Summarized with AI on November 18. AI used: claude-sonnet-4-5-20250929.

Hello. I am attempting to set up a remote mySQL database (on Amazon RDS) to contain sensitive shop-dependent data such as SHOPIFY_API_KEY, SHOPIFY_API_SECRET, GraphQL’s adminAccessToken, GraphQL’s url Endpoint, as well as some of my own shop-dependent data, etc.

I can do the import and access the database just fine from the web/index.js file, BUT I cannot get beyond the import statement in my page code located in the web/frontend/pages directory.

The import statement is this:

import mysql from 'mysql2';

The error message I see in the chrome console when this statement exists is this:

TypeError: Cannot read properties of undefined (reading ‘NODE_DEBUG’)> at mysql2.js?t=1689528236624&v=ab90f474:13449:24> at Array.forEach (

Can anyone shed some light on this? Thanks so much!

Cheers jb