Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API Auth throwing errors in container #19

Open
hawk4031 opened this issue Feb 18, 2022 · 1 comment
Open

API Auth throwing errors in container #19

hawk4031 opened this issue Feb 18, 2022 · 1 comment

Comments

@hawk4031
Copy link
Member

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

pyrrha-api-auth         | > [email protected] 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! [email protected] 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 [email protected] 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
Copy link
Member

Thank you @hawk4031. Related to Pyrrha-Platform/Pyrrha-Dashboard#145

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants