Re: Issues with npm pakcages, .env variables & constants in Shopify React + Node

Issues with npm pakcages, .env variables & constants in Shopify React + Node

arnav98
Shopify Partner
26 1 7

Hi,

 

I am using a React + Node template (pre Remix).

I am facing issues -

  1. I am defining the SHOPIFY_BASE_URL variable for API endpoints, but it is coming as undefined when I try to use it in my web/frontend folder, is there any specific format w.r.t. to defining and using env variables in the Shopify React app template.
  2. I am defining the endpoints constant inside a new folder web/api/frontend/api/constants.js but when I'm trying to import them and use them I'm facing an issue in my app, it throws the following error in the console.image.png
  3. I'm trying to install npm packages for React inside the web/frontend/ folder but it is corrupting my node modules and throwing random errors, clean re-install of node modules also doesn't fix it, I have to replace the node modules from a backup of the same Shopify app I have as a .zip file.

How can I work to resolve these issues, is there any guidelines/best practices or some tutorial (couldn't find much regarding these issues in shopify.dev)

Reply 1 (1)

SBD_
Shopify Staff
1829 271 414

Hey @arnav98 

 

Please raise this as an issue here: https://github.com/Shopify/shopify-app-template-node

Scott | Developer Advocate @ Shopify