fission-codes / wnfs-migration

Apache License 2.0
4 stars 1 forks source link

Package compatibility issue on node-fetch #2

Closed ngeojiajun closed 2 years ago

ngeojiajun commented 2 years ago

Summary

npm install wnfs-migration install the wrong version of the node-fetch due.

Problem

The package.json of the indirect dependency of the wnfs-migration specifies the direct url instead of the version instead. This results in the npm to instead install the lastest version of the node-fetch rather than download and install the package on the provided url.

Impact

wnfs-migration command will fail to execute due to the breaking changes to it which have prevented the CommonJS style require('node-fetch') from working.

Solution

The possible solution that are found is to manually perform the installation of the said package

sudo rm -rf /usr/lib/node_modules/wnfs-migration/node_modules/node-fetch
wget https://registry.npmjs.org/@achingbrain/node-fetch/-/node-fetch-2.6.7.tgz
tar zxvf node-fetch-2.6.7.tgz
sudo mv package /usr/lib/node_modules/wnfs-migration/node_modules/node-fetch

Detail

To Reproduce Install the package through the command npm install wnfs-migration then run the wnfs-migration

Expected behavior The application should starts up

Desktop (please complete the following information):

jeffgca commented 2 years ago

I think I just ran into this same issue, the error I saw was:

➜  fission git:(main) wnfs-migration
/Users/jeff/code/node/globals/node_modules/native-fetch/src/index.js:12
    default: require('node-fetch').default,
             ^

Error [ERR_REQUIRE_ESM]: require() of ES Module /Users/jeff/code/node/globals/node_modules/node-fetch/src/index.js from /Users/jeff/code/node/globals/node_modules/native-fetch/src/index.js not supported.
Instead change the require of /Users/jeff/code/node/globals/node_modules/node-fetch/src/index.js in /Users/jeff/code/node/globals/node_modules/native-fetch/src/index.js to a dynamic import() which is available in all CommonJS modules.
    at Object.<anonymous> (/Users/jeff/code/node/globals/node_modules/native-fetch/src/index.js:12:14)
    at Object.<anonymous> (/Users/jeff/code/node/globals/node_modules/ipfs-utils/src/fetch.js:9:20)
    at Object.<anonymous> (/Users/jeff/code/node/globals/node_modules/ipfs-utils/src/http/fetch.node.js:2:62)
    at Object.<anonymous> (/Users/jeff/code/node/globals/node_modules/ipfs-utils/src/http/fetch.js:8:20)
    at Object.<anonymous> (/Users/jeff/code/node/globals/node_modules/ipfs-utils/src/http.js:4:37)
    at async Promise.all (index 0) {
  code: 'ERR_REQUIRE_ESM'
}
icidasset commented 2 years ago

Thanks! Fixed in 2.0.4