-
Notifications
You must be signed in to change notification settings - Fork 1.2k
ReferenceError: TextDecoder is not defined #3620
Comments
Thank you for submitting your first issue to this repository! A maintainer will be here shortly to triage and review.
Finally, remember to use https://discuss.ipfs.io if you just need general support. |
I'm having the same issue when running the Create React App example project |
Same here. Created a massively simplified CRA repo to reproduce: https://github.com/elmariachi111/ipfs-textencoder-demo |
What version of node are you running? |
Built that with node 12.22, 14.15, 15.14 tried with yarn, npm, pnpm. |
node:10.16.0-alpine [Docker] |
guess that's related to the latest multibase releases ( js-ipfs/packages/ipfs-core/package.json Line 114 in 74bfce3
|
@ekumahost please upgrade to a supported node version - 14 or 15. @elmariachi111 you are running in a browser and likely have a different problem |
it's very lkely an issue with CRA. Runs fine inside nextjs & parcel, created 2 PRs for that: https://github.com/elmariachi111/ipfs-textencoder-demo/pulls . It's quite likely that somewhen on the way CRA support broke. I just checked whether your official CRA sample (without Typescript) runs, but I found that by plainly building and running it, it shows the same error as above... (so https://github.com/ipfs/js-ipfs/tree/master/examples/browser-create-react-app is also not working here, node 14.15.3 |
I have a project that is also being affected by this. Dependency tree
Avoid using (^) in the dependencies, it is really dangerous. |
A workaround, while it doesn't get fixed:
Commit that introduced the problem: Gozala/web-encoding@3992702 |
I think this is going to fix the issue. trying to test and verify. |
@RomarQ think it's not helping if I install web-encoding locally ;) But you know what? When I add
to my |
I have upgraded node to version >14.x and issue fixed. |
…b-encoding-1.1.4 Bump web-encoding from 1.1.3 to 1.1.4
I am facing the same while retrieving the data from mongodb. |
@achingbrain This is not working for me in ipfs-webui with node version 16.12.0 when I'm trying to upgrade dependencies: ipfs/ipfs-webui#1965 > run-s -cl test:unit test:build test:e2e
[test:unit ]
[test:unit ] > [email protected] test:unit /Users/sgtpooki/code/work/protocol.ai/ipfs/webui
[test:unit ] > react-scripts test --env=jsdom --runInBand --watchAll=false
[test:unit ]
[test:unit ] watchman warning: Recrawled this watch 1513 times, most recently because:
[test:unit ] MustScanSubDirs UserDroppedTo resolve, please review the information on
[test:unit ] https://facebook.github.io/watchman/docs/troubleshooting.html#recrawl
[test:unit ] To clear this warning, run:
[test:unit ] `watchman watch-del '/Users/sgtpooki/code/work/protocol.ai/ipfs/webui' ; watchman watch-project '/Users/sgtpooki/code/work/protocol.ai/ipfs/webui'`
[test:unit ]
[test:unit ] PASS src/bundles/node-bandwidth-chart.test.js
[test:unit ] PASS src/bundles/peer-locations.test.js
[test:unit ] PASS src/loader/AsyncRequestLoader.test.js
[test:unit ] PASS src/lib/files.test.js
[test:unit ] PASS src/lib/dnd-backend.test.js
[test:unit ] PASS src/lib/count-dirs.test.js
[test:unit ] FAIL src/bundles/files.test.js
[test:unit ] ● Test suite failed to run
[test:unit ]
[test:unit ] ReferenceError: TextDecoder is not defined
[test:unit ]
[test:unit ] 8 | import map from 'it-map'
[test:unit ] 9 | import last from 'it-last'
[test:unit ] > 10 | import CID from 'cids'
[test:unit ] | ^
[test:unit ] 11 |
[test:unit ] 12 | import { spawn, perform, send, ensureMFS, Channel, sortFiles, infoFromPath } from './utils'
[test:unit ] 13 | import { IGNORED_FILES, ACTIONS } from './consts'
[test:unit ]
[test:unit ] at Object.<anonymous> (node_modules/.pnpm/[email protected]/node_modules/multibase/src/util.js:3:21)
[test:unit ] at Object.<anonymous> (node_modules/.pnpm/[email protected]/node_modules/multibase/src/base.js:3:24)
[test:unit ] at Object.<anonymous> (node_modules/.pnpm/[email protected]/node_modules/multibase/src/constants.js:4:14)
[test:unit ] at Object.<anonymous> (node_modules/.pnpm/[email protected]/node_modules/multibase/src/index.js:7:19)
[test:unit ] at Object.<anonymous> (node_modules/.pnpm/[email protected]/node_modules/multihashes/src/index.js:6:19)
[test:unit ] at Object.<anonymous> (node_modules/.pnpm/[email protected]/node_modules/cids/src/index.js:3:12)
[test:unit ] at Object.<anonymous> (src/bundles/files/actions.js:10:1)
[test:unit ] at Object.<anonymous> (src/bundles/files/index.js:4:1)
[test:unit ] at Object.<anonymous> (src/bundles/files.test.js:3:1)
[test:unit ]
[test:unit ] FAIL src/bundles/peer-bandwidth.test.js
[test:unit ] ● Test suite failed to run
[test:unit ]
[test:unit ] ReferenceError: TextDecoder is not defined
[test:unit ]
[test:unit ] 1 | import multihashing from 'multihashing-async'
[test:unit ] > 2 | import CID from 'cids'
[test:unit ] | ^
[test:unit ] 3 | import { promisify } from 'util'
[test:unit ] 4 | import Crypto from 'crypto'
[test:unit ] 5 |
[test:unit ]
[test:unit ] at Object.<anonymous> (node_modules/.pnpm/[email protected]/node_modules/multibase/src/util.js:3:21)
[test:unit ] at Object.<anonymous> (node_modules/.pnpm/[email protected]/node_modules/multibase/src/base.js:3:24)
[test:unit ] at Object.<anonymous> (node_modules/.pnpm/[email protected]/node_modules/multibase/src/constants.js:4:14)
[test:unit ] at Object.<anonymous> (node_modules/.pnpm/[email protected]/node_modules/multibase/src/index.js:7:19)
[test:unit ] at Object.<anonymous> (node_modules/.pnpm/[email protected]/node_modules/multihashes/src/index.js:6:19)
[test:unit ] at Object.<anonymous> (node_modules/.pnpm/[email protected]/node_modules/cids/src/index.js:3:12)
[test:unit ] at Object.<anonymous> (test/helpers/cid.js:2:1)
[test:unit ] at Object.<anonymous> (src/bundles/peer-bandwidth.test.js:4:1)
[test:unit ]
[test:unit ] FAIL src/bundles/notify.test.js
[test:unit ] ● Test suite failed to run
[test:unit ]
[test:unit ] ReferenceError: TextDecoder is not defined
[test:unit ]
[test:unit ] 8 | import map from 'it-map'
[test:unit ] 9 | import last from 'it-last'
[test:unit ] > 10 | import CID from 'cids'
[test:unit ] | ^
[test:unit ] 11 |
[test:unit ] 12 | import { spawn, perform, send, ensureMFS, Channel, sortFiles, infoFromPath } from './utils'
[test:unit ] 13 | import { IGNORED_FILES, ACTIONS } from './consts'
[test:unit ]
[test:unit ] at Object.<anonymous> (node_modules/.pnpm/[email protected]/node_modules/multibase/src/util.js:3:21)
[test:unit ] at Object.<anonymous> (node_modules/.pnpm/[email protected]/node_modules/multibase/src/base.js:3:24)
[test:unit ] at Object.<anonymous> (node_modules/.pnpm/[email protected]/node_modules/multibase/src/constants.js:4:14)
[test:unit ] at Object.<anonymous> (node_modules/.pnpm/[email protected]/node_modules/multibase/src/index.js:7:19)
[test:unit ] at Object.<anonymous> (node_modules/.pnpm/[email protected]/node_modules/multihashes/src/index.js:6:19)
[test:unit ] at Object.<anonymous> (node_modules/.pnpm/[email protected]/node_modules/cids/src/index.js:3:12)
[test:unit ] at Object.<anonymous> (src/bundles/files/actions.js:10:1)
[test:unit ] at Object.<anonymous> (src/bundles/files/index.js:4:1)
[test:unit ] at Object.<anonymous> (src/bundles/notify.js:3:1)
[test:unit ] at Object.<anonymous> (src/bundles/notify.test.js:3:1)
[test:unit ]
[test:unit ] FAIL src/bundles/analytics.test.js
[test:unit ] ● Test suite failed to run
[test:unit ]
[test:unit ] ReferenceError: TextDecoder is not defined
[test:unit ]
[test:unit ] > 1 | import multiaddr from 'multiaddr'
[test:unit ] | ^
[test:unit ] 2 | import HttpClient from 'ipfs-http-client'
[test:unit ] 3 | // @ts-ignore
[test:unit ] 4 | import { getIpfs, providers } from 'ipfs-provider'
[test:unit ]
[test:unit ] at Object.<anonymous> (node_modules/.pnpm/[email protected]/node_modules/multibase/src/util.js:3:21)
[test:unit ] at Object.<anonymous> (node_modules/.pnpm/[email protected]/node_modules/multibase/src/base.js:3:24)
[test:unit ] at Object.<anonymous> (node_modules/.pnpm/[email protected]/node_modules/multibase/src/constants.js:4:14)
[test:unit ] at Object.<anonymous> (node_modules/.pnpm/[email protected]/node_modules/multibase/src/index.js:7:19)
[test:unit ] at Object.<anonymous> (node_modules/.pnpm/[email protected]/node_modules/multihashes/src/index.js:6:19)
[test:unit ] at Object.<anonymous> (node_modules/.pnpm/[email protected]/node_modules/cids/src/index.js:3:12)
[test:unit ] at Object.<anonymous> (node_modules/.pnpm/[email protected][email protected]/node_modules/multiaddr/src/convert.js:5:13)
[test:unit ] at Object.<anonymous> (node_modules/.pnpm/[email protected][email protected]/node_modules/multiaddr/src/codec.js:3:17)
[test:unit ] at Object.<anonymous> (node_modules/.pnpm/[email protected][email protected]/node_modules/multiaddr/src/index.js:3:15)
[test:unit ] at Object.<anonymous> (src/bundles/ipfs-provider.js:1:1)
[test:unit ] at Object.<anonymous> (src/bundles/analytics.js:10:1)
[test:unit ] at Object.<anonymous> (src/bundles/analytics.test.js:3:1)
[test:unit ]
[test:unit ] Test Suites: 4 failed, 1 skipped, 6 passed, 10 of 11 total
[test:unit ] Tests: 4 skipped, 35 passed, 39 total
[test:unit ] Snapshots: 0 total
[test:unit ] Time: 3.02 s
[test:unit ] Ran all test suites.
[test:unit ] ELIFECYCLE Command failed with exit code 1. What is the fix for this? |
This may be related to your use of JSDom in the test execution: jsdom/jsdom#2524 |
js-ipfs is being deprecated in favor of Helia. You can #4336 and read the migration guide. Please feel to reopen with any comments by 2023-06-02. We will do a final pass on reopened issues afterward (see #4336). FYI, my previous issue was resolved with a jsdom global setup file. |
My script been throwing this error no headways..
any idea
Severity: high
Description:
2021-04-09 12:22:05
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
2021-04-09 12:22:05
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
2021-04-09 12:22:05
at Module.load (internal/modules/cjs/loader.js:653:32)
2021-04-09 12:22:05
at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10)
2021-04-09 12:22:05
at Module._compile (internal/modules/cjs/loader.js:776:30)
2021-04-09 12:22:05
at Object. (/www/node_modules/multibase/src/constants.js:4:14)
2021-04-09 12:22:05
at require (internal/modules/cjs/helpers.js:25:18)
2021-04-09 12:22:05
at Module.require (internal/modules/cjs/loader.js:690:17)
2021-04-09 12:22:05
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
2021-04-09 12:22:05
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
2021-04-09 12:22:05
at Module.load (internal/modules/cjs/loader.js:653:32)
2021-04-09 12:22:05
at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10)
2021-04-09 12:22:05
at Module._compile (internal/modules/cjs/loader.js:776:30)
2021-04-09 12:22:05
at Object. (/www/node_modules/multibase/src/base.js:3:24)
2021-04-09 12:22:05
at require (internal/modules/cjs/helpers.js:25:18)
2021-04-09 12:22:05
at Module.require (internal/modules/cjs/loader.js:690:17)
2021-04-09 12:22:05
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
2021-04-09 12:22:05
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
2021-04-09 12:22:05
at Module.load (internal/modules/cjs/loader.js:653:32)
2021-04-09 12:22:05
at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10)
2021-04-09 12:22:05
at Module._compile (internal/modules/cjs/loader.js:776:30)
2021-04-09 12:22:05
at Object. (/www/node_modules/multibase/src/util.js:3:21)
2021-04-09 12:22:05
ReferenceError: TextDecoder is not defined
2021-04-09 12:22:05
2021-04-09 12:22:05
^
2021-04-09 12:22:05
const textDecoder = new TextDecoder()
2021-04-09 12:22:05
/www/node_modules/multibase/src/util.js:3
Steps to reproduce the error:
The text was updated successfully, but these errors were encountered: