Skip to content

Add version to got dependency #76

Open
@gonza7aav

Description

@gonza7aav

If we just copy the dependencies installation code from JavaScript (Node.js) environment set up, we'll get the following

npm install needle
npm install got
npm install oauth-1.0a

This means we are installing the latest version of got. Since v12.0.0 the package is pure ESM, so we must use import to load it or we'll get the following error

~/index.js:3
const got = require('got');
            ^

Error [ERR_REQUIRE_ESM]: require() of ES Module ~/node_modules/got/dist/source/index.js from ~/index.js not supported.
Instead change the require of ~/node_modules/got/dist/source/index.js in ~/index.js to a dynamic import() which is available in all CommonJS modules.
    at Object.<anonymous> (~/index.js:3:13) {
  code: 'ERR_REQUIRE_ESM'
}

To reproduce the error, you need to install the dependencies the way the README.md says and try to run any example that requires got package.

There are two solutions as I see, we could rewrite all the scripts that fail or we could install a previous version to v12.0.0. So in order to run the examples as they are without any script change, I suggest adding a version range with a "less than" symbol.

npm install got@'<12.0.0'

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions