Pyrrha-Platform / Pyrrha-Dashboard

This repository contains the next generation in-progress Pyrrha (created by Prometeo) solution dashboard based on the Carbon Design System and React.
Apache License 2.0
6 stars 7 forks source link

node-fetch update causing errors #145

Open upkarlidder opened 2 years ago

upkarlidder commented 2 years ago

Is your feature request related to a problem? Please describe.

node --version         
v16.14.0

npm --version
8.3.1

Dependabot updated node-fetch from 2.x to 3.x. This causes the following error when running yarn run start-ui

[2022-02-16T10:02:02.057] [INFO] appid-WebAppStrategy-config - redirectUri http://localhost:3000/ibm/cloud/appid/callback
/Pyrrha-Dashboard/pyrrha-dashboard/api-auth/services/appId.js:1
const fetch = require('node-fetch');
              ^

Error [ERR_REQUIRE_ESM]: require() of ES Module /Pyrrha-Dashboard/pyrrha-dashboard/api-auth/node_modules/node-fetch/src/index.js from /Pyrrha-Dashboard/pyrrha-dashboard/api-auth/services/appId.js not supported.
Instead change the require of index.js in /Pyrrha-Dashboard/pyrrha-dashboard/api-auth/services/appId.js to a dynamic import() which is available in all CommonJS modules.
    at Object.<anonymous> (/Pyrrha-Dashboard/pyrrha-dashboard/api-auth/services/appId.js:1:15)
    at Object.<anonymous> (/Pyrrha-Dashboard/pyrrha-dashboard/api-auth/rest/routes.js:5:25)
    at Object.<anonymous> (/Pyrrha-Dashboard/pyrrha-dashboard/api-auth/server.js:11:16) {
  code: 'ERR_REQUIRE_ESM'

Describe the solution you'd like The error is documented here - https://github.com/node-fetch/node-fetch#commonjs

node-fetch from v3 is an ESM-only module - you are not able to import it with require().

If you cannot switch to ESM, please use v2 which remains compatible with CommonJS. Critical bug fixes will continue to be published for v2.

Alternatively, you can use the async import() function from CommonJS to load node-fetch asynchronously

We can also look at other libraries like axios.

Describe alternatives you've considered N/A

Additional context Add any other context or screenshots about the feature request here.

krook commented 2 years ago

Is this now resolved by reverting to an older version @upkarlidder?

upkarlidder commented 2 years ago

Yes. That was the quick fix. Need to check if there are any security issues with the lower version. What got fixed in the next version and if we need to move up.

krook commented 2 years ago

Any update on this one @upkarlidder?