Pyrrha-Platform / Pyrrha-Deployment-Configurations

A centralized place for Helm charts, GitHub Actions, and other local and cloud deployment resources.
Apache License 2.0
1 stars 3 forks source link

API Auth throwing errors in container #19

Open hawk4031 opened 2 years ago

hawk4031 commented 2 years ago

When running the Docker Compose instructions, the container builds fine, but the following stack trace shows in the logs:

pyrrha-api-auth         | > api-auth@0.0.1 start /app
pyrrha-api-auth         | > node server.js
pyrrha-api-auth         |
pyrrha-api-auth         | [2022-02-18T19:04:33.070] [INFO] appid-sdk - Initialized
pyrrha-api-auth         | [2022-02-18T19:04:33.132] [INFO] appid-WebAppStrategy-config - clientId 4161b7b9-770b-4027-aeba-7894174fbc5c
pyrrha-api-auth         | [2022-02-18T19:04:33.132] [INFO] appid-WebAppStrategy-config - tenantId b971b89e-1319-4eb6-bbb6-331a289e963e
pyrrha-api-auth         | [2022-02-18T19:04:33.132] [INFO] appid-WebAppStrategy-config - secret [CANNOT LOG SECRET]
pyrrha-api-auth         | [2022-02-18T19:04:33.132] [INFO] appid-WebAppStrategy-config - oauthServerUrl https://us-south.appid.cloud.ibm.com/oauth/v4/b971b89e-1319-4eb6-bbb6-331a289e963e
pyrrha-api-auth         | [2022-02-18T19:04:33.132] [INFO] appid-WebAppStrategy-config - redirectUri http://localhost:3000/ibm/cloud/appid/callback
pyrrha-api-auth         | internal/modules/cjs/loader.js:1015
pyrrha-api-auth         |       throw new ERR_REQUIRE_ESM(filename, parentPath, packageJsonPath);
pyrrha-api-auth         |       ^
pyrrha-api-auth         |
pyrrha-api-auth         | Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: /app/node_modules/node-fetch/src/index.js
pyrrha-api-auth         | require() of ES modules is not supported.
pyrrha-api-auth         | require() of /app/node_modules/node-fetch/src/index.js from /app/services/appId.js is an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which defines all .js files in that package scope as ES modules.
pyrrha-api-auth         | Instead rename index.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from /app/node_modules/node-fetch/package.json.
pyrrha-api-auth         |
pyrrha-api-auth         |     at Object.Module._extensions..js (internal/modules/cjs/loader.js:1015:13)
pyrrha-api-auth         |     at Module.load (internal/modules/cjs/loader.js:863:32)
pyrrha-api-auth         |     at Function.Module._load (internal/modules/cjs/loader.js:708:14)
pyrrha-api-auth         |     at Module.require (internal/modules/cjs/loader.js:887:19)
pyrrha-api-auth         |     at require (internal/modules/cjs/helpers.js:74:18)
pyrrha-api-auth         |     at Object.<anonymous> (/app/services/appId.js:1:15)
pyrrha-api-auth         |     at Module._compile (internal/modules/cjs/loader.js:999:30)
pyrrha-api-auth         |     at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
pyrrha-api-auth         |     at Module.load (internal/modules/cjs/loader.js:863:32)
pyrrha-api-auth         |     at Function.Module._load (internal/modules/cjs/loader.js:708:14) {
pyrrha-api-auth         |   code: 'ERR_REQUIRE_ESM'
pyrrha-api-auth         | }
pyrrha-api-auth         | npm ERR! code ELIFECYCLE
pyrrha-api-auth         | npm ERR! errno 1
pyrrha-api-auth         | npm ERR! api-auth@0.0.1 start: `node server.js`
pyrrha-api-auth         | npm ERR! Exit status 1
pyrrha-api-auth         | npm ERR!
pyrrha-api-auth         | npm ERR! Failed at the api-auth@0.0.1 start script.
pyrrha-api-auth         | npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
pyrrha-api-auth         |
pyrrha-api-auth         | npm ERR! A complete log of this run can be found in:
pyrrha-api-auth         | npm ERR!     /root/.npm/_logs/2022-02-18T19_04_33_155Z-debug.log

It appears one of the modules should use import instead of require

upkarlidder commented 2 years ago

Thank you @hawk4031. Related to https://github.com/Pyrrha-Platform/Pyrrha-Dashboard/issues/145