Giter Club home page Giter Club logo

Comments (10)

brunohafonso avatar brunohafonso commented on June 8, 2024

Using the latest version of the package 0.10.2

from node-youtube-music.

baptisteArno avatar baptisteArno commented on June 8, 2024

What code are you trying to execute?

from node-youtube-music.

gloirekiba avatar gloirekiba commented on June 8, 2024

i got the same error just trying a simple code like this in typescript

import { searchMusics } from "node-youtube-music";

searchMusics("Hello").then((musics) => {
  console.log(musics);
});

from node-youtube-music.

baptisteArno avatar baptisteArno commented on June 8, 2024

What's your set up? How can I reproduce?

from node-youtube-music.

gloirekiba avatar gloirekiba commented on June 8, 2024

nothing crazy out here, just a fresh project, i uploaded to github here https://github.com/gloirekiba/groove-tube

from node-youtube-music.

gloirekiba avatar gloirekiba commented on June 8, 2024

just run npm run dev

from node-youtube-music.

baptisteArno avatar baptisteArno commented on June 8, 2024

This lib is an ES Module, so try to run it with tsnd-esm instead of tsnd. Would that fix the issue?

from node-youtube-music.

dkregen avatar dkregen commented on June 8, 2024

Same to me. I'm using CommonJS in my tsconfig.json configuration:

{
  "compilerOptions": {
    "suppressImplicitAnyIndexErrors": true,
    "noImplicitAny": false,
    "noImplicitThis": false,
    "strictNullChecks": false,
    "allowSyntheticDefaultImports": true,
    "declaration": true,
    "module": "CommonJS",
    "target": "es5",
    "sourceMap": true,
    "outDir": "dist",
    "esModuleInterop": true
  },
  "include": [
    "src/**/*"
  ]
}

Try to call a method that will produce the error.

import { searchMusics } from "node-youtube-music";

searchMusics("Hello").then((musics) => {
  console.log(musics);
});

Solution:
To import an ES module in CommonJS, you can use the import() function with a dynamic import statement.

const music = await import('node-youtube-music')
const r = await music.searchMusics(q)

Another workaround I tried is to use version 0.7.0

from node-youtube-music.

supersu-man avatar supersu-man commented on June 8, 2024

Error [ERR_REQUIRE_ESM]: require() of ES Module D:\Projects\sangeet-discordbot\node_modules\got\dist\source\index.js from D:\Projects\sangeet-discordbot\node_modules\node-youtube-music\dist\index.js not supported.

I am trying to run .ts file and I get this error.

For now I am switching back to older version as a workaround.

from node-youtube-music.

baptisteArno avatar baptisteArno commented on June 8, 2024

Hey guys, read this: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c#pure-esm-package

It 100% applies to node-youtube-music.

from node-youtube-music.

Related Issues (16)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.