js-ipfs: 0.62.1 will not start daemon in windows 10: `PubsubRouter is not a constructor`
- 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'
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.
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"
}
}
What is the Node version you're using? Can you please also first try updating to the latest Node version and then report back?
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
2022-03-25 conversation: maintainers will attempt to repo.
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.
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
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]
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.
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.
This should be fixed in the latest patch release - can you please give it a try?
getting this exact same error
@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]
@resession can you confirm the version of
libp2p-gossipsubyou are using?Run this in your project/where npm has installed js-ipfs:
npm ls libp2p-gossipsubE.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
@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]
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 - 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.
npm install --save abortcontroller-polyfill
const { AbortController } = globalThis
換成
const { AbortController, abortableFetch } = require('abortcontroller-polyfill/dist/cjs-ponyfill');
const { fetch } = abortableFetch(require('node-fetch'));
可正常運作
Closing as this appears to have been resolved in the latest version.