js-ipfs icon indicating copy to clipboard operation
js-ipfs copied to clipboard

js-ipfs: 0.62.1 will not start daemon in windows 10: `PubsubRouter is not a constructor`

Open D4di69 opened this issue 4 years ago • 18 comments

  • Version:

node.js : 16 js-ipfs: 0.62.1

  • Platform:

windows, cmd

  • Subsystem:

not known

Severity:

Critical

Description:

i wanted to try this api with the windows 10 cmd, i opened the cmd as an administrator and typed first "npm install -g ipfs" and npm installed it, i have npm installed and also set to the path. then i typed "jsipfs daemon" to start the daemon but i got this error: TypeError: Class extends value undefined is not a constructor or null at Object.<anonymous> (C:\Users\sussq\AppData\Roaming\npm\node_modules\ipfs\node_modules\timeout-abort-controller\index.js:8:33) at Module._compile (internal/modules/cjs/loader.js:1085:14) at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10) at Module.load (internal/modules/cjs/loader.js:950:32) at Function.Module._load (internal/modules/cjs/loader.js:790:12) at ModuleWrap.<anonymous> (internal/modules/esm/translators.js:199:29) at ModuleJob.run (internal/modules/esm/module_job.js:183:25) at async Loader.import (internal/modules/esm/loader.js:178:24) at async Object.loadESM (internal/process/esm_loader.js:68:5)

Steps to reproduce the error:

install this with npm on win cmd and then type 'jsipfs daemon'

D4di69 avatar Mar 15 '22 17:03 D4di69

Thank you for submitting your first issue to this repository! A maintainer will be here shortly to triage and review. In the meantime, please double-check that you have provided all the necessary information to make this process easy! Any information that can help save additional round trips is useful! We currently aim to give initial feedback within two business days. If this does not happen, feel free to leave a comment. Please keep an eye on how this issue will be labeled, as labels give an overview of priorities, assignments and additional actions requested by the maintainers:

  • "Priority" labels will show how urgent this is for the team.
  • "Status" labels will show if this is ready to be worked on, blocked, or in progress.
  • "Need" labels will indicate if additional input or analysis is required.

Finally, remember to use https://discuss.ipfs.io if you just need general support.

welcome[bot] avatar Mar 15 '22 17:03 welcome[bot]

I'm seeing the exact same error message while following the OrbitDB Guide.

Here's a simple code-snippet one can use to reproduce the problem:

// NOTE: I'm getting the same error with `ipfs` and `ipfs-core`.

// const IPFS = require("ipfs-core");
const IPFS = require("ipfs");
const OrbitDB = require("orbit-db");

async function main() {
  const ipfs1_config = { repo: "./ipfs1" };
  const ipfs1 = await IPFS.create(ipfs1_config);
}

main();

Here's the package.json file:

{
  "name": "foo",
  "version": "0.1.0",
  "main": "main.js",
  "dependencies": {
    "go-ipfs": "^0.12.0",
    "ipfs": "^0.62.1",
    "ipfs-core": "^0.14.1",
    "ipfsd-ctl": "^10.0.6",
    "orbit-db": "^0.28.3"
  }
}

pmuens avatar Mar 17 '22 08:03 pmuens

What is the Node version you're using? Can you please also first try updating to the latest Node version and then report back?

BigLep avatar Mar 18 '22 14:03 BigLep

What is the Node version you're using? Can you please also first try updating to the latest Node version and then report back?

I updated the issue, now you can look what node version im using, i also tried the latest version of node but i get the same error

D4di69 avatar Mar 18 '22 17:03 D4di69

2022-03-25 conversation: maintainers will attempt to repo.

BigLep avatar Mar 25 '22 14:03 BigLep

I can't replicate using

Windows 10 node 16.41.2 ipfs 0.62.1

@D4di69 can you please confirm the exact version of node you are using - eg. 16.x.x., not just 16.

achingbrain avatar Mar 25 '22 14:03 achingbrain

I was able to reproduce some kind of error using PowerShell in administrator mode. The same occurs in a regular(old) terminal, and new windows terminal

PS C:\Users\Administrator>  jsipfs daemon
Initializing IPFS daemon...
System version: x64/win32
Node.js version: 16.14.2
generating Ed25519 keypair...
PubsubRouter is not a constructor
PS C:\Users\Administrator> node --version
v16.14.2
PS C:\Users\Administrator> nvm arch
System Default: 64-bit.
Currently Configured: 64-bit.
PS C:\Users\Administrator> node -e 'console.log(process.arch)'
x64
PS C:\Users\Administrator> jsipfs --version
unknown
PS C:\Users\Administrator> npm ls
Administrator@ C:\Users\Administrator
`-- [email protected]
PS C:\Users\Administrator> systeminfo | findstr /B /C:"OS Name" /C:"OS Version"
OS Name:                   Microsoft Windows 10 Pro
OS Version:                10.0.19044 N/A Build 19044

SgtPooki avatar Mar 28 '22 17:03 SgtPooki

I was able to get a daemon running by downgrading ipfs to @0.61.0:

PS C:\Users\Administrator> npm install -g [email protected]
npm WARN deprecated [email protected]: this library is no longer supported
npm WARN deprecated [email protected]: Please upgrade to latest, formidable@v2 or formidable@v3! Check these notes: https://bit.ly/2ZEqIau
npm WARN deprecated [email protected]: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.
npm WARN deprecated [email protected]: request has been deprecated, see https://github.com/request/request/issues/3142

added 6 packages, removed 3 packages, changed 673 packages, and audited 681 packages in 28s

7 vulnerabilities (6 moderate, 1 high)

To address issues that do not require attention, run:
  npm audit fix

To address all issues (including breaking changes), run:
  npm audit fix --force

Run `npm audit` for details.
PS C:\Users\Administrator> jsipfs daemon
Initializing IPFS daemon...
System version: x64/win32
Node.js version: 16.14.2
Incompatible repo version. Migration needed. Pass --migrate for automatic migration
PS C:\Users\Administrator> jsipfs daemon --migrate
Initializing IPFS daemon...
System version: x64/win32
Node.js version: 16.14.2
The ipfs-repo-migrations package does not have all migration to migrate from version 11 to 12
PS C:\Users\Administrator> rm .jsipfs

Confirm
The item at C:\Users\Administrator\.jsipfs has children and the Recurse parameter was not specified. If you continue,
all children will be removed with the item. Are you sure you want to continue?
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help (default is "Y"): A
PS C:\Users\Administrator> jsipfs daemon
Initializing IPFS daemon...
System version: x64/win32
Node.js version: 16.14.2
generating Ed25519 keypair...
to get started, enter:

        jsipfs cat /ipfs/QmRaaUwTNfwgFZpeUy8qrZwrp2dY4kCKmmB5xEqvH3vtD1/readme

Swarm listening on /ip4/172.20.224.1/tcp/4002/p2p/12D3KooWMV5SKK2rraFNgtPtY3yzrEtEBKfdHeLETEeQzQx8UzpY
Swarm listening on /ip4/192.168.3.51/tcp/4002/p2p/12D3KooWMV5SKK2rraFNgtPtY3yzrEtEBKfdHeLETEeQzQx8UzpY
Swarm listening on /ip4/127.0.0.1/tcp/4002/p2p/12D3KooWMV5SKK2rraFNgtPtY3yzrEtEBKfdHeLETEeQzQx8UzpY
Swarm listening on /ip4/127.0.0.1/tcp/4003/ws/p2p/12D3KooWMV5SKK2rraFNgtPtY3yzrEtEBKfdHeLETEeQzQx8UzpY
js-ipfs version: 0.13.0
HTTP API listening on /ip4/127.0.0.1/tcp/5002/http
gRPC listening on /ip4/127.0.0.1/tcp/5003/ws
Gateway (read only) listening on /ip4/127.0.0.1/tcp/9090/http
Web UI available at http://127.0.0.1:5002/webui
Daemon is ready
PS C:\Users\Administrator> npm -g ls
C:\Program Files\nodejs -> .\
+-- [email protected]
+-- [email protected]
`-- [email protected]

SgtPooki avatar Mar 28 '22 18:03 SgtPooki

Hi, I can confirm this also happened on fresh installation (I'm not Linux / Tech savvy, so pardon if I did something wrong)

I'm on linux Ubuntu 18.04.6 LTS

Here's the details

~$ npm -g ls
/path/to/home/ipfs/.nvm/versions/node/v16.14.2/lib
+-- [email protected]
+-- [email protected]
`-- [email protected]

When doing jsipfs daemon it gives

jsipfs daemon
Initializing IPFS daemon...
System version: x64/linux
Node.js version: 16.14.2
generating Ed25519 keypair...
PubsubRouter is not a constructor
~$ jsipfs add ./test-1.png
PubsubRouter is not a constructor

But, when, downgrade to [email protected], it works well as @SgtPooki mentioned.

wandyyd avatar Apr 01 '22 08:04 wandyyd

It looks like [email protected] caused this issue, it doesn't exist with 0.13.0 - https://github.com/ChainSafe/js-libp2p-gossipsub/issues/224 or 0.12.0 which is what [email protected] uses.

achingbrain avatar Apr 04 '22 07:04 achingbrain

This should be fixed in the latest patch release - can you please give it a try?

achingbrain avatar Apr 05 '22 15:04 achingbrain

getting this exact same error

resession avatar Apr 13 '22 03:04 resession

@resession can you confirm the version of libp2p-gossipsub you are using?

Run this in your project/where npm has installed js-ipfs:

npm ls libp2p-gossipsub

E.g. I use nvm to manage node installs, so I do:

% cd $NVM_DIR/versions/node/`node -v`/lib/node_modules/ipfs
% npm ls libp2p-gossipsub
[email protected] /Users/alex/.nvm/versions/node/v16.13.0/lib/node_modules/ipfs
└─┬ [email protected]
  └─┬ [email protected]
    └── [email protected]

achingbrain avatar Apr 13 '22 08:04 achingbrain

@resession can you confirm the version of libp2p-gossipsub you are using?

Run this in your project/where npm has installed js-ipfs:

npm ls libp2p-gossipsub

E.g. I use nvm to manage node installs, so I do:

% cd $NVM_DIR/versions/node/`node -v`/lib/node_modules/ipfs
% npm ls libp2p-gossipsub
[email protected] /Users/alex/.nvm/versions/node/v16.13.0/lib/node_modules/ipfs
└─┬ [email protected]
  └─┬ [email protected]
    └── [email protected]

i downgraded the ipfs version, i'll install the latest version again and post the results here tomorrow

resession avatar Apr 14 '22 03:04 resession

@achingbrain

i ran that command, here is what i get

[email protected] F:\Proj\Production\project-test └─┬ [email protected] └─┬ [email protected] └─┬ [email protected] └── [email protected]

resession avatar Apr 15 '22 02:04 resession

Hmm, weird - that should work. Can you please create a small repro repo and link to it here? Just an index.js that starts a js-ipfs node, a package.json and a package-lock.json should be enough.

achingbrain avatar Apr 19 '22 17:04 achingbrain

@achingbrain - thanks for that! I already test on my own and it works so far. At least new update solve the problem I mentioned previously (below)

Previous related issue > Hi, I can confirm this also happened on fresh installation (I'm not Linux / Tech savvy, so pardon if I did something wrong) > > I'm on linux Ubuntu 18.04.6 LTS > > Here's the details > > ~$ npm -g ls > /path/to/home/ipfs/.nvm/versions/node/v16.14.2/lib > +-- [email protected] > +-- [email protected] > `-- [email protected] > > When doing `jsipfs daemon` it gives > > jsipfs daemon > Initializing IPFS daemon... > System version: x64/linux > Node.js version: 16.14.2 > generating Ed25519 keypair... > PubsubRouter is not a constructor > ~$ jsipfs add ./test-1.png > PubsubRouter is not a constructor > > But, when, downgrade to [email protected], it works well as @SgtPooki mentioned.

wandyyd avatar May 06 '22 08:05 wandyyd

npm install --save abortcontroller-polyfill

const { AbortController } = globalThis 換成

const { AbortController, abortableFetch } = require('abortcontroller-polyfill/dist/cjs-ponyfill');
const { fetch } = abortableFetch(require('node-fetch'));

可正常運作

hjkl451203 avatar May 23 '22 05:05 hjkl451203

Closing as this appears to have been resolved in the latest version.

achingbrain avatar May 22 '23 14:05 achingbrain