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

Shopify Partner
180 8 49

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 (<anonymous>)
at ../../node_modules/mysql2/lib/packets/index.js (mysql2.js?t=1689528236624&v=ab90f474:13447:29)
at __require2 (chunk-7REXU52E.js?v=784c7085:19:50)
at ../../node_modules/mysql2/lib/connection.js (mysql2.js?t=1689528236624&v=ab90f474:18400:19)
at __require2 (chunk-7REXU52E.js?v=784c7085:19:50)
at ../../node_modules/mysql2/index.js (mysql2.js?t=1689528236624&v=ab90f474:19749:22)
at __require2 (chunk-7REXU52E.js?v=784c7085:19:50)
at mysql2.js?t=1689528236624&v=ab90f474:19814:16

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


Cheers jb

Replies 0 (0)