expressjs / express

Fast, unopinionated, minimalist web framework for node.

Home Page:https://expressjs.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Shopify App Running on React/Express: Cannot read properties of undefined (reading 'from')

16BitS3G4l opened this issue · comments

Hi, it would be great if somebody could take a look at an issue (a bug I suspect) I'm having. Appreciate any time spent.

Context:

I'm building a Shopify app (based on the Shopify Polaris framework) and haven't experienced this issue before. Throughout the development of the application, no errors of this type have been encountered. It seems very arbitrary and unlikely, but after small updates, this error started popping up and interfering with programming - I removed all changes I made that day to see if it would help, but it didn't. I've attached as much information as I find relevant below. Please let me know if it's not structured enough, not enough information, or too much information.

I'm running the latest version of express (see below for package.json)

{
  "name": "shopify-app-node",
  "private": true,
  "scripts": {
    "build": "npm run build:client",
    "build:client": "vite build --outDir dist/client",
    "debug": "node --inspect-brk server/index.js",
    "dev": "cross-env NODE_ENV=development nodemon server/index.js --watch ./server",
    "prepare": "husky install",
    "preserve": "npm run build",
    "serve": "cross-env NODE_ENV=production node server/index.js",
    "start": "npm run serve",
    "test": "vitest --reporter=verbose"
  },
  "type": "module",
  "engines": {
    "node": ">=16.13.0"
  },
  "dependencies": {
    "@apollo/client": "^3.5.10",
    "@shopify/app-bridge": "^2.0.22",
    "@shopify/app-bridge-react": "^2.0.24",
    "@shopify/app-bridge-utils": "^2.0.23",
    "@shopify/polaris": "^9.2.2",
    "@shopify/shopify-api": "^3.0.0",
    "@vitejs/plugin-react": "1.2.0",
    "compression": "^1.7.4",
    "cookie-parser": "^1.4.6",
    "cross-env": "^7.0.3",
    "dotenv": "^16.0.0",
    "express": "^4.17.3",
    "graphql": "^16.3.0",
    "react": "^17.0.2",
    "react-color": "^2.19.3",
    "react-dom": "^17.0.2",
    "react-grid-gallery": "^0.5.5",
    "react-qr-code": "^2.0.5",
    "serve-static": "^1.14.1",
    "vite": "^2.9.1"
  },
  "devDependencies": {
    "husky": "^7.0.4",
    "nodemon": "^2.0.15",
    "prettier": "^2.6.2",
    "pretty-quick": "^3.1.3",
    "supertest": "^6.2.2",
    "vitest": "^0.9.2"
  }
}

Trace from chrome devtools:

Uncaught TypeError: Cannot read properties of undefined (reading 'from')
    at node_modules/express/node_modules/safe-buffer/index.js (index.js:12:12)
    at __require2 (chunk-5537U2Q2.js?v=c1edecdf:47:50)
    at node_modules/express/lib/utils.js (utils.js:15:14)
    at __require2 (chunk-5537U2Q2.js?v=c1edecdf:47:50)
    at node_modules/express/lib/application.js (application.js:24:19)
    at __require2 (chunk-5537U2Q2.js?v=c1edecdf:47:50)
    at node_modules/express/lib/express.js (express.js:18:13)
    at __require2 (chunk-5537U2Q2.js?v=c1edecdf:47:50)
    at node_modules/express/index.js (index.js:11:18)
    at __require2 (chunk-5537U2Q2.js?v=c1edecdf:47:50)
node_modules/express/node_modules/safe-buffer/index.js @ index.js:12
__require2 @ chunk-5537U2Q2.js?v=c1edecdf:47
node_modules/express/lib/utils.js @ utils.js:15
__require2 @ chunk-5537U2Q2.js?v=c1edecdf:47
node_modules/express/lib/application.js @ application.js:24
__require2 @ chunk-5537U2Q2.js?v=c1edecdf:47
node_modules/express/lib/express.js @ express.js:18
__require2 @ chunk-5537U2Q2.js?v=c1edecdf:47
node_modules/express/index.js @ index.js:11
__require2 @ chunk-5537U2Q2.js?v=c1edecdf:47
(anonymous) @ dep:express:1

Here are the code lines highlighted in the trace:

if (Buffer.from && Buffer.alloc && Buffer.allocUnsafe && Buffer.allocUnsafeSlow) {
  module.exports = buffer
var Buffer = require('safe-buffer').Buffer
var compileETag = require('./utils').compileETag;
  return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
module.exports = require('./lib/express');

Please let me know if there is any other information that might help out.

Thank you.

Hu @dev-segal sorry to hear about the troubles. I'm not sure what the issue is just with the information provided. Is it possible you can provide code we can run and the steps to reproduce the issue? We can then help debug and see what is causing it.

Hi Doug, my apologies. It seems my editor somehow added an import (without my knowing) and it lead to this error. It took a substantial amount of time (and embarrassing) but it seems like we should close this non existent bug :)

Thanks for your time,
Yehoshua

No problem, gald you got it resolved. Sorry for taking so long to get back to you in the first place!