Skip to content

ReferenceError: TextEncoder is not defined #10713

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
yhojann-cl opened this issue Sep 12, 2021 · 3 comments
Closed

ReferenceError: TextEncoder is not defined #10713

yhojann-cl opened this issue Sep 12, 2021 · 3 comments
Labels
can't reproduce Mongoose devs have been unable to reproduce this issue. Close after 14 days of inactivity.

Comments

@yhojann-cl
Copy link

yhojann-cl commented Sep 12, 2021

Do you want to request a feature or report a bug?

Bug

What is the current behavior?

after install mongoose show me a error

const utf8Encoder = new TextEncoder();
                    ^

ReferenceError: TextEncoder is not defined

If the current behavior is a bug, please provide the steps to reproduce.

in a clean installation run the following commands

$ npm init;
$ npm install mongoose;
$ echo "const mongoose = require('mongoose');" > index.js
$ node index.js;

What is the expected behavior?

show the error

/app/node_modules/whatwg-url/dist/encoding.js:2
const utf8Encoder = new TextEncoder();
                    ^

ReferenceError: TextEncoder is not defined
    at Object.<anonymous> (/app/node_modules/whatwg-url/dist/encoding.js:2:21)
    at Module._compile (internal/modules/cjs/loader.js:778:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
    at Function.Module._load (internal/modules/cjs/loader.js:585:3)
    at Module.require (internal/modules/cjs/loader.js:692:17)
    at require (internal/modules/cjs/helpers.js:25:18)
    at Object.<anonymous> (/app/node_modules/whatwg-url/dist/url-state-machine.js:5:34)
    at Module._compile (internal/modules/cjs/loader.js:778:30)

What are the versions of Node.js, Mongoose and MongoDB you are using? Note that "latest" is not a version.

$ node -v
v14.17.5

$ npm -v
6.14.14

$ sudo docker exec -it database-mongodb bash;
root@37127c24c366:/# mongo
MongoDB shell version v5.0.2
...

$ lsb_release -a
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 20.04.3 LTS
Release:	20.04
Codename:	focal

$ tail -13 package.json 
    "dependencies": {
        "bcryptjs": "^2.4.3",
        "body-parser": "^1.19.0",
        "cors": "^2.8.5",
        "dotenv": "^10.0.0",
        "express": "^4.17.1",
        "joi": "^17.4.2",
        "jsonwebtoken": "^8.5.1",
        "mongodb": "^4.1.1",
        "mongoose": "^6.0.5",
        "uuid": "^8.3.2"
    }
}
...

Reference: https://github.com/jsdom/whatwg-url/issues/209
@IslandRhythms IslandRhythms added the can't reproduce Mongoose devs have been unable to reproduce this issue. Close after 14 days of inactivity. label Sep 13, 2021
@vkarpov15
Copy link
Collaborator

@yhojann-cl
Copy link
Author

I don't use reactjs.

I saw that issue but I could not answer in the same thread to clarify that it is not solved with an update or changing the framework, that's why I had to make a new thread.

@yhojann-cl
Copy link
Author

yhojann-cl commented Sep 17, 2021

I resolve the problem, i have installed two version of node but one from apt and other from n package manager, but in the package.json i declared start scripts as: "start": "/usr/bin/node index.js":

$ which nodejs
/usr/bin/nodejs
$ which node
/usr/local/bin/node
$ nodejs -v
v10.19.0
$ node -v
v14.17.5

My script call /usr/bin/node but it is referenced to /usr/bin/nodejs. Works uninstalling nodejs from apt using apt remove nodejs and change full path to relative path, like as "start": "node index.js". Now works fine :D

@Automattic Automattic deleted a comment from Newgin-sam Oct 11, 2021
@Automattic Automattic locked and limited conversation to collaborators Oct 11, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
can't reproduce Mongoose devs have been unable to reproduce this issue. Close after 14 days of inactivity.
Projects
None yet
Development

No branches or pull requests

3 participants