/src/security/index not found on Vercel serverlesss function.
I'm using strong-soap basically with require const soap = require('strong-soap').soap;
App works perfectly fine on local ngrok but it crashes on Vercel. Is there anything we can do to fix this?
The error in the Vercel log:
Cannot find module './src/security/index'
Require stack:
- /var/task/node_modules/strong-soap/index.js
- /var/task/aramex.js
- /var/task/handlers.js
- /var/task/routes.js
- /var/task/index.js
Did you forget to add it to "dependencies" in `package.json`?
Error: Runtime exited with error: exit status 1
Runtime.ExitError
I'm trying to compile strong-soap as a binary in a custom JavaScript solution, and stumbled upon the same error message.
Apply this patch, but you may run into other errors relating to dynamic imports.
diff --git a/node_modules/strong-soap/index.js b/node_modules/strong-soap/index.js
index 701ff00..e44a612 100644
--- a/node_modules/strong-soap/index.js
+++ b/node_modules/strong-soap/index.js
@@ -5,20 +5,17 @@
'use strict';
-var base = './lib/';
+var base = './src/';
var nodeVersion = process.versions.node;
var major = Number(nodeVersion.split('.')[0]);
-if (major >= 4) {
- base = './src/';
-}
-var securityModules = require(base + 'security/index');
+var securityModules = require('./src/security/index');
module.exports = {
- 'soap': require(base + 'soap'),
- 'http': require(base + 'http'),
- 'QName': require(base + 'parser/qname'),
- 'WSDL': require(base + 'parser/wsdl'),
+ 'soap': require('./src/soap'),
+ 'http': require('./src/http'),
+ 'QName': require('./src/parser/qname'),
+ 'WSDL': require('./src/parser/wsdl'),
};
for (var i in securityModules) {
Also from README « Node.js version 10, 12, and 14 are officially supported. We dropped version 8 support in 3.0.0. », then I wonder why there is a piece of code to support node.js 4.
My two cents, and hoping it helps.
And for the dynamic imports, as a workaround, I am presently using a different entry point to my custom www.js application:
/* eslint-disable */
// The packaging tool is unable to recognize dynamic imports,
// however we can workaround this by doing the imports ourselves
require("strong-globalize/cldr/cldr_32.0.1.json");
// find ./node_modules/strong-soap/intl/ -type f | sed 's/.\/node_modules\///g' | sort | sed 's/.*/require\("&"\);/g'
require("strong-soap/intl/cs/messages.json");
require("strong-soap/intl/de/messages.json");
require("strong-soap/intl/en/messages.json");
require("strong-soap/intl/es/messages.json");
require("strong-soap/intl/fr/messages.json");
require("strong-soap/intl/it/messages.json");
require("strong-soap/intl/ja/messages.json");
require("strong-soap/intl/ko/messages.json");
require("strong-soap/intl/nl/messages.json");
require("strong-soap/intl/pl/messages.json");
require("strong-soap/intl/pt/messages.json");
require("strong-soap/intl/ru/messages.json");
require("strong-soap/intl/tr/messages.json");
require("strong-soap/intl/zh-Hans/messages.json");
require("strong-soap/intl/zh-Hant/messages.json");
require("strong-soap/intl/zz/messages_inverted.json");
require("strong-soap/intl/zz/messages.json");
require("./www.js");
And for the dynamic imports, as a workaround, I am presently using a different entry point to my custom
www.jsapplication:/* eslint-disable */ // The packaging tool is unable to recognize dynamic imports, // however we can workaround this by doing the imports ourselves require("strong-globalize/cldr/cldr_32.0.1.json"); // find ./node_modules/strong-soap/intl/ -type f | sed 's/.\/node_modules\///g' | sort | sed 's/.*/require\("&"\);/g' require("strong-soap/intl/cs/messages.json"); require("strong-soap/intl/de/messages.json"); require("strong-soap/intl/en/messages.json"); require("strong-soap/intl/es/messages.json"); require("strong-soap/intl/fr/messages.json"); require("strong-soap/intl/it/messages.json"); require("strong-soap/intl/ja/messages.json"); require("strong-soap/intl/ko/messages.json"); require("strong-soap/intl/nl/messages.json"); require("strong-soap/intl/pl/messages.json"); require("strong-soap/intl/pt/messages.json"); require("strong-soap/intl/ru/messages.json"); require("strong-soap/intl/tr/messages.json"); require("strong-soap/intl/zh-Hans/messages.json"); require("strong-soap/intl/zh-Hant/messages.json"); require("strong-soap/intl/zz/messages_inverted.json"); require("strong-soap/intl/zz/messages.json"); require("./www.js");
Did you have to do anything special to get cldr to work? I'm getting similar issues using Firebase Functions. I've changed my entry point to a new file that includes the above, but get the following:
Error: ENOENT: no such file or directory, lstat '/src/dist/apps/cldr'
at Object.realpathSync (node:fs:2655:7)
at alreadyScanned (/node_modules/strong-globalize/src/helper.ts:221:56)
at enumerateFilesSyncPriv (/node_modules/strong-globalize/src/helper.ts:243:7)
at enumerateFilesSync (/node_modules/strong-globalize/src/helper.ts:209:10)
at getSupportedLanguages (/node_modules/strong-globalize/src/helper.ts:719:3)
at Object.isSupportedLanguage (/node_modules/strong-globalize/src/helper.ts:708:37)
at osLanguage (/node_modules/strong-globalize/src/globalize.ts:50:14)
at node_modules/strong-globalize/lib/globalize.js (/node_modules/strong-globalize/src/globalize.ts:42:17)
at __require (/src/dist/apps/cred-cloud-api/main.js:13:51)
at node_modules/strong-globalize/lib/strong-globalize.js (/node_modules/strong-globalize/src/strong-globalize.ts:7:1) {
errno: -2,
syscall: 'lstat',
code: 'ENOENT',
path: '/src/dist/apps/cldr'
}
Did you have to copy any additional packages into your bundle?
@noddy-cred I think you may need to declare cldr explicitly (and other dependencies of strong-soap?) as a dependency of your firebase project to make the SDK deploy that module.
PS: I've added after www.js require some stuff like the following:
// ... the forced requires
// entry point
require("./www.js");
// code to dump require cache and find something interesting
setTimeout(() => {
let dump = Object.keys(require.cache);
dump = JSON.stringify(dump, null, 2);
require('fs').writeFileSync('dump.txt', dump, 'utf-8');
console.log('dumped requires');
}, 60000).unref();
To dump all imported modules after I call the APIs on www.js to see what gets required.
IMO strong-soap needs to be redesigned for the serverless world. I've found another alternative/solution for my issue, but am bound by NDA.