App reviews, troubleshooting, and recommendations
Hi,
I have an app that is using the previous node js template, and deployed on fly.io. Last week it was up and running without problem, I moved back to my dev environment for a couple touch ups. Now when I switch back my redirect URL's to my fly.io app react is not being recognized in the index.js file in the asset output file of the embedded app.
index-d27b9a09.js:79 Uncaught ReferenceError: require is not defined
at index-d27b9a09.js:79:72236
The funny thing is that this works completely fine if I just run my app locally:
npm run dev
I noticed that I no longer have the banner that shopify plans to upgrade me to simplified deployment (i believe that's what it was called). Could this be the cause of the failures? If so does anyone know how I can fix the build process? Thanks in advance.
Solved! Go to the solution
This is an accepted solution.
Hey Samir, the shopify team totally borked this one and have provided absolutely sub standard service when addressing them about the issue. The solution is below, update your vite.config with the commonJs transformations as such:
export default defineConfig({
root: dirname(fileURLToPath(import.meta.url)),
plugins: [react()],
define: {
"process.env.SHOPIFY_API_KEY": JSON.stringify(process.env.SHOPIFY_API_KEY),
},
// ADD THIS LINE TO CONVERT THE require()
build: {
commonjsOptions: {
transformMixedEsModules: true,
}
},
// END LINE
resolve: {
preserveSymlinks: true,
},
server: {
host: "localhost",
port: process.env.FRONTEND_PORT,
hmr: hmrConfig,
proxy: {
"^/(\\?.*)?$": proxyOptions,
"^/api(/|(\\?.*)?$)": proxyOptions,
"^/bundle/checkout(\\?.*)?$": proxyOptions,
},
},
});
Could really use some help on this. Updated details below:
index-d27b9a09.js:79 Uncaught ReferenceError: require is not defined at index-d27b9a09.js:79:72236
import { defineConfig } from "vite"; import { dirname } from "path"; import { fileURLToPath } from "url"; import https from "https"; import react from "@vitejs/plugin-react"; if ( process.env.npm_lifecycle_event === "build" && !process.env.CI && !process.env.SHOPIFY_API_KEY ) { console.warn( "\nBuilding the frontend app without an API key. The frontend build will not run without an API key. Set the SHOPIFY_API_KEY environment variable when running the build command.\n" ); } const proxyOptions = { target: `http://127.0.0.1:${process.env.BACKEND_PORT}`, changeOrigin: false, secure: true, ws: false, }; const host = process.env.HOST ? process.env.HOST.replace(/https?:\/\//, "") : "localhost"; let hmrConfig; if (host === "localhost") { hmrConfig = { protocol: "ws", host: "localhost", port: 64999, clientPort: 64999, }; } else { hmrConfig = { protocol: "wss", host: host, port: process.env.FRONTEND_PORT, clientPort: 443, }; } export default defineConfig({ root: dirname(fileURLToPath(import.meta.url)), plugins: [react()], define: { "process.env.SHOPIFY_API_KEY": JSON.stringify(process.env.SHOPIFY_API_KEY), }, resolve: { preserveSymlinks: true, }, server: { host: "localhost", port: process.env.FRONTEND_PORT, hmr: hmrConfig, proxy: { "^/(\\?.*)?$": proxyOptions, "^/api(/|(\\?.*)?$)": proxyOptions, "^/bundle/checkout(\\?.*)?$": proxyOptions, }, }, });
Facing the same issue, were you able to resolve it?
Please let me know
Facing the exact same issue and got completely stuck. The previous version of the App has stopped working too. @Shopify Team : This is a CRITICAL issue and definitely a bug at your side.
Can some-one look into this at priority ?
This is an accepted solution.
Hey Samir, the shopify team totally borked this one and have provided absolutely sub standard service when addressing them about the issue. The solution is below, update your vite.config with the commonJs transformations as such:
export default defineConfig({
root: dirname(fileURLToPath(import.meta.url)),
plugins: [react()],
define: {
"process.env.SHOPIFY_API_KEY": JSON.stringify(process.env.SHOPIFY_API_KEY),
},
// ADD THIS LINE TO CONVERT THE require()
build: {
commonjsOptions: {
transformMixedEsModules: true,
}
},
// END LINE
resolve: {
preserveSymlinks: true,
},
server: {
host: "localhost",
port: process.env.FRONTEND_PORT,
hmr: hmrConfig,
proxy: {
"^/(\\?.*)?$": proxyOptions,
"^/api(/|(\\?.*)?$)": proxyOptions,
"^/bundle/checkout(\\?.*)?$": proxyOptions,
},
},
});
Shopify and our financial partners regularly review and update verification requiremen...
By Jacqui Mar 14, 2025Unlock the potential of marketing on your business growth with Shopify Academy's late...
By Shopify Mar 12, 2025Learn how to increase conversion rates in every stage of the customer journey by enroll...
By Shopify Mar 5, 2025