Error 500 "Cannot find module 'jsonwebtoken" on local NodeJS server

Win 10
W 4.5.1
Local Own Server NodeJS

I have a project that uses Google API via service account.
I didn’t tested this function for month, but opened it today and figure, that it doesn’t work locally with error:
{status: “500”, code: “MODULE_NOT_FOUND”,…}
code: “MODULE_NOT_FOUND”
message: "Cannot find module 'jsonwebtoken

On the external server everything is fine.
I’ve tried reinstalling NodeJS modules, but without success.

When I switched to the newly added Wappler local server, the error disappeared.
So I haven’t any problems now.
But anyway I decided to report.

Also, maybe it is my personal bug because of this topic Google API 401 Error "Access Token Expired" (session not refreshing?)
As seen, I added some custom made files to the project as temporary fixes.

Full error text:

  server-connect:app   auth: 'oauth',
  server-connect:server     at Function.Module._load (node:internal/modules/cjs/loader:772:27)
  server-connect:server     at Module.require (node:internal/modules/cjs/loader:999:19)
  server-connect:server     at require (node:internal/modules/cjs/helpers:93:18)
  server-connect:server     at App.setJSONWebToken (C:\Users\nick\Wappler Projects\squiz-online\lib\core\app.js:350:21)
  server-connect:server     at App.getJSONWebToken (C:\Users\nick\Wappler Projects\squiz-online\lib\core\app.js:378:25)
  server-connect:server     at OAuth2.init (C:\Users\nick\Wappler Projects\squiz-online\lib\oauth\index.js:38:40)
  server-connect:server     at App.setOAuthProvider (C:\Users\nick\Wappler Projects\squiz-online\lib\core\app.js:223:32)
  server-connect:server     at App.getOAuthProvider (C:\Users\nick\Wappler Projects\squiz-online\lib\core\app.js:239:31)
  server-connect:server     at App.send (C:\Users\nick\Wappler Projects\squiz-online\lib\modules\api.js:57:41) {
  server-connect:server   code: 'MODULE_NOT_FOUND',
  server-connect:server   requireStack: [
  server-connect:server     'C:\\Users\\nick\\Wappler Projects\\squiz-online\\lib\\core\\app.js',
  server-connect:server     'C:\\Users\\nick\\Wappler Projects\\squiz-online\\lib\\core\\middleware.js',
  server-connect:server     'C:\\Users\\nick\\Wappler Projects\\squiz-online\\lib\\setup\\routes.js',
  server-connect:server     'C:\\Users\\nick\\Wappler Projects\\squiz-online\\lib\\server.js',
  server-connect:server     'C:\\Users\\nick\\Wappler Projects\\squiz-online\\index.js'
  server-connect:server   ]
  server-connect:server }

Verify that json web token is in your package.json

If you are publishing to Plesk you need to run in their admin again the nom install so that all node modules are installed there.

Indeed, the jsonwebtoken is missing in the list of dependencies. How can I fix this?

Got it, would keep it in mind. Though at the moment the problem is only on local hosting.

Just edit thee server action using the JWT and save it. It should bee then auto added.

I’ve edited one server action that has a step with OAuth2 with JWT and saved it.
But the package.json doesn’t have changed.

You really should have also a global JWT provider when using JWT in OAuth2 - it is required. Then the module will be auto added automatically.

This one?

ok found the problem - will be fixed in the upcoming update

1 Like

Fixed in Wappler 4.5.3

This topic was automatically closed after 47 hours. New replies are no longer allowed.