Have trouble setting up jsonwebtoken

Hi, I have followed the steps on this page Unable to install n8n-nodes-module and have edited the package.json and added @types/jsonwebtoken": “^8.5.2” and installed lerna and run lerna bootstrap --hoist.

Still getting the error below. I am running n8n on a linux mint local host to test this out.

Any ideas what the issue is please?

Thank you!

Paul

ERROR: Cannot find module ‘jsonwebtoken’ [Line 1]

Details

Stack

VMError: Cannot find module 'jsonwebtoken'
    at Resolver.resolveFull (/usr/local/lib/node_modules/n8n/node_modules/vm2/lib/resolver.js:110:9)
    at Resolver.resolve (/usr/local/lib/node_modules/n8n/node_modules/vm2/lib/resolver.js:105:15)
    at ReadOnlyHandler.apply (/usr/local/lib/node_modules/n8n/node_modules/vm2/lib/bridge.js:479:11)
    at requireImpl (/usr/local/lib/node_modules/n8n/node_modules/vm2/lib/setup-node-sandbox.js:84:28)
    at require (/usr/local/lib/node_modules/n8n/node_modules/vm2/lib/setup-node-sandbox.js:165:10)
    at /usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/Function:1:110
    at /usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/Function:43:2
    at BaseHandler.apply (/usr/local/lib/node_modules/n8n/node_modules/vm2/lib/bridge.js:479:11)
    at NodeVM.run (/usr/local/lib/node_modules/n8n/node_modules/vm2/lib/nodevm.js:425:23)
    at Object.execute (/usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/nodes/Function/Function.node.ts:122:22)

Hey @paul2000,

Have you set NODE_FUNCTION_ALLOW_EXTERNAL so n8n knows you can use it?

Hi @Jon, Just tried: [email protected]:~$ cd /usr/local/lib/node_modules/n8n
[email protected]:/usr/local/lib/node_modules/n8n$ set NODE_FUNCTION_ALLOW_EXTERNAL=*

But same error. Any other ideas please?

Thank you

Paul

Hi @paul2000,

When you set that option did you then restart n8n so it can pick up the change?

Hi @Jon, Yes I have restarted. So to recap I can see the required files here: ‘/usr/local/lib/node_modules/n8n/node_modules/jsonwebtoken’ and I have added “@types/jsonwebtoken”: “^8.5.1”, to the package.json file that lives here '/usr/local/lib/node_modules/n8n/package.json

I have run sudo lerna bootstrap --hoist and it seems to have worked without error. I have then restated n8n.

Anything I have missed please?

Thank you

Paul

Hi @paul2000,

That should be everything, As a test could you run the below in a function node and see if the browser console shows the correct option.

console.log($env["NODE_FUNCTION_ALLOW_EXTERNAL"]);

Thinking about I have not seen any one use the lerna approach unless they are running from source, If you are using the NPM option to run n8n you might be able to just get away with running npm install -g @types/jsonwebtoken

Hi @Jon,

I ran the function node and got:

ERROR: No data got returned. Always an object has to be returned!

Details

Time

11/04/2022, 17:50:35

Cause
Data below may contain sensitive information. Proceed with caution when sharing.

{

}

Stack

NodeOperationError: No data got returned. Always an object has to be returned!
    at Object.execute (/usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/nodes/FunctionItem/FunctionItem.node.ts:161:12)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at /usr/local/lib/node_modules/n8n/node_modules/n8n-core/src/WorkflowExecute.ts:814:26

I also tired the npm install -g @types/jsonwebtoken but still get the original error.

Any other ideas please? Thank you!

1 Like

Thanks @Jon, It was that the

NODE_FUNCTION_ALLOW_EXTERNAL

was not set. My son helped me debug, - to be honest he is the brains of the out fit! Thanks again!

1 Like

Hey @paul2000,

No problem at all I am just happy it is working :tada: