DrBrainX
Contributor
Contributor

vRA 8.2 ABX Nodejs Action Error: Cannot find module '/function/main')

Jump to solution

Hi Guys, 

I have created based on a tutorial the following nodejs script and imported this as a zip into an nodejs action. 

But if I start the script (FaaS onPrem) am getting the following error Message (Error: Cannot find module '/function/main'): 

script name is main.js and the entry point handler which have been configured properly in the ABX action. 

 

exit status 1
internal/modules/cjs/loader.js:1088
throw err;
^

Error: Cannot find module '/function/main'
Require stack:
- /function/abx_wrapper.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:1085:15)
at Function.Module._load (internal/modules/cjs/loader.js:928:27)
at Module.require (internal/modules/cjs/loader.js:1145:19)
at require (internal/modules/cjs/helpers.js:75:18)
at Object.<anonymous> (/function/abx_wrapper.js:415:20)
at Module._compile (internal/modules/cjs/loader.js:1256:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1277:10)
at Module.load (internal/modules/cjs/loader.js:1105:32)
at Function.Module._load (internal/modules/cjs/loader.js:967:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12) {
code: 'MODULE_NOT_FOUND',
requireStack: [ '/function/abx_wrapper.js' ]
}

 
Code: 
const request = require('request');

const request = require('request');
exports.handler = (contextinputscallback=> {
    const vRAUrl = inputs.vRAUrl;
    const token = "some token";
     request.get(vRAUrl + '/iaas/api/projects', { 'auth': { 'bearer': token } }, function
    (errorresponsebody) {
        console.log('Got response ' + body);
        callback(nullJSON.parse(body));
    });
}
0 Kudos
1 Solution

Accepted Solutions
DrBrainX
Contributor
Contributor

Hi,


I don’t have an Internet connection on the appliance, so can not fetch the request dependencies. For this reason have to import it as a zip file.

 Cheers Ertan

 

 

 

 

 

 

 

View solution in original post

0 Kudos
7 Replies
lnairn
VMware Employee
VMware Employee

Hi @DrBrainX ,

If you create the action from scratch ... works? I think this is a zip formatting issue.... If no sensitive information is there, can you attach the zip file?

Regards,

Leandro.

 

0 Kudos
DrBrainX
Contributor
Contributor

Hi, 

you can find the zip at the attachment.

 

Cheers Ertan 

 

0 Kudos
lnairn
VMware Employee
VMware Employee

Hi,

As far as I can see quickly, inside the zip file you have a folder and then the content. You should have all files and folders in the root directory for the zip file, not inside a folder. 

This is from our documentation

"Both your script and dependency elements must be stored at the root level of the ZIP package. When creating the ZIP package in a Linux environment, you might encounter a problem where the package content is not stored at the root level. If you encounter this problem, create the package by running the zip -r command in your command-line shell."

Can you modify the zip structure and try again?

Regards,

Leandro.

 

0 Kudos
DrBrainX
Contributor
Contributor

Hi, 

now it's running with the following error message: 

 

DrBrainX_0-1606317467255.png

 

0 Kudos
lnairn
VMware Employee
VMware Employee

Strange.... if you create the script directly in vRA - just to test -, do you have any error in the execution?

0 Kudos
DrBrainX
Contributor
Contributor

Hi,


I don’t have an Internet connection on the appliance, so can not fetch the request dependencies. For this reason have to import it as a zip file.

 Cheers Ertan

 

 

 

 

 

 

 

View solution in original post

0 Kudos
DrBrainX
Contributor
Contributor

Hi, 

I have added an upstream proxy to my vRA appliance and started the nodejs script direcetly as an Action but I do still get the following error message: 

exit status 1
internal/modules/cjs/loader.js:1088
  throw err;
  ^
Error: Cannot find module 'request'
Require stack:
- /function/client_main.js
- /function/abx_wrapper.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:1085:15)
    at Function.Module._load (internal/modules/cjs/loader.js:928:27)
    at Module.require (internal/modules/cjs/loader.js:1145:19)
    at require (internal/modules/cjs/helpers.js:75:18)
    at Object.<anonymous> (/function/client_main.js:1:17)
    at Module._compile (internal/modules/cjs/loader.js:1256:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1277:10)
    at Module.load (internal/modules/cjs/loader.js:1105:32)
    at Function.Module._load (internal/modules/cjs/loader.js:967:14)
    at Module.require (internal/modules/cjs/loader.js:1145:19) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [ '/function/client_main.js', '/function/abx_wrapper.js' ]
}
 

Cheers Ertan 

 

 

 

  

 

 

 

 

0 Kudos