Cannot find module - Urgent help needed

V5.1.3 - MacOs - Nodejs - Postgresql

I just deployed an update to production, I’m getting this error in api’s:

    {
  "status": "500",
  "code": "MODULE_NOT_FOUND",
  "message": "Cannot find module '@aws-sdk/middleware-endpoint'\nRequire stack:\n- /opt/node_app/node_modules/@aws-sdk/s3-request-presigner/dist-cjs/getSignedUrl.js\n- /opt/node_app/node_modules/@aws-sdk/s3-request-presigner/dist-cjs/index.js\n- /opt/node_app/lib/modules/s3.js\n- /opt/node_app/lib/core/app.js\n- /opt/node_app/lib/core/middleware.js\n- /opt/node_app/lib/setup/routes.js\n- /opt/node_app/lib/server.js\n- /opt/node_app/index.js",
  "stack": "Error: Cannot find module '@aws-sdk/middleware-endpoint'\nRequire stack:\n- /opt/node_app/node_modules/@aws-sdk/s3-request-presigner/dist-cjs/getSignedUrl.js\n- /opt/node_app/node_modules/@aws-sdk/s3-request-presigner/dist-cjs/index.js\n- /opt/node_app/lib/modules/s3.js\n- /opt/node_app/lib/core/app.js\n- /opt/node_app/lib/core/middleware.js\n- /opt/node_app/lib/setup/routes.js\n- /opt/node_app/lib/server.js\n- /opt/node_app/index.js\n    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:956:15)\n    at Function.Module._load (node:internal/modules/cjs/loader:804:27)\n    at Module.require (node:internal/modules/cjs/loader:1028:19)\n    at require (node:internal/modules/cjs/helpers:102:18)\n    at Object.<anonymous> (/opt/node_app/node_modules/@aws-sdk/s3-request-presigner/dist-cjs/getSignedUrl.js:4:31)\n    at Module._compile (node:internal/modules/cjs/loader:1126:14)\n    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1180:10)\n    at Module.load (node:internal/modules/cjs/loader:1004:32)\n    at Function.Module._load (node:internal/modules/cjs/loader:839:12)\n    at Module.require (node:internal/modules/cjs/loader:1028:19)"
}

Didn’t touch anything related to these things. No idea if it’s a problem from Wappler side, or something from that module as I found this discussion from yesterday/today:

Please help as the production app isn’t working right now (Good lesson to first push to staging)

Have you tried the fix posted on the link you’ve given?

If we change our package.json from
@aws-sdk/s3-request-presigner”: “^3.178.0” => “@aws-sdk/s3-request-presigner”: “3.67.0”
it fixes the issue

Seems to be a bug in the aws sdk and needs to be resolved there first.

Yes I tried, it doesn’t work, same error

On my localhost/dev target all works fine, what could be the difference with the production target?

I tried this suggestion too:

Didn’t work

Try to click - “Install node packages” when your Production target is selected:

image

Unfortunately didn’t work…

Ok fixed!

This was actually the solution, before I installed middleware-bucket-endpoint by accident.

npm i @aws-sdk/middleware-endpoint -> and then deploy fixed the problem

Wasn’t the solution but thanks for the reminder that you can upload individual stuff! I was deploying the whole thing when making a tiny change in one single server connect api. Now I uploaded the changed api and it takes less than a second. Will save a lot of time!

You should never do that Brian… as there might be OS dependent modules and for example your local windows node_modules won’t work on Linux server …

When changing package.json - you should just run npm install to install the exact needed node modules on your remote server or if you are using docker it is all done for you.

Yes george, i just learned that! :grinning:

1 Like