Comments (10)
Using the latest version of the package 0.10.2
from node-youtube-music.
What code are you trying to execute?
from node-youtube-music.
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.
What's your set up? How can I reproduce?
from node-youtube-music.
nothing crazy out here, just a fresh project, i uploaded to github here https://github.com/gloirekiba/groove-tube
from node-youtube-music.
just run npm run dev
from node-youtube-music.
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.
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.
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.
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)
- Error while installing the package. HOT 2
- API does not work in Russia server HOT 3
- Use API key from YouTube Data API HOT 1
- listMusicsFromPlaylist seems to be broken HOT 1
- Searching playlists throws error HOT 4
- Error: node_modules/node-youtube-music/dist/index.js:104 undefined HOT 10
- console spammed with errors when using listMusicsFromPlaylist but works
- listMusicsFromPlaylist thumbnails and searchMusics thumbnails being different HOT 2
- Add a license. HOT 1
- Error [ERR_REQUIRE_ESM]: require() of ES Module ...\node_modules\node-youtube-music\dist\index.js from ...\index.js not supported. HOT 1
- Error ytMusic.searchMusics HOT 1
- Artists support HOT 5
- Parsers fail, new Youtube API? HOT 1
- album is artist with search()
- Suggestions seem to be broken
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from node-youtube-music.