NuclearPlayer / extract-sptf-playlist

You know what it's for (extracting spotify and youtube playlist via puppeteer without login)
GNU General Public License v3.0
25 stars 2 forks source link

Running the file still isn't working #3

Open rx570gtx1060 opened 2 years ago

rx570gtx1060 commented 2 years ago

2

Running the file still didn't work. Here is my syntax

const { getYoutubePlaylist } = require('extract-sptf-playlist'); const url = '';

const playlist = await getYoutubePlaylist(url, { filePath: '2data.json', displayProcess: true, headless: true});

haidang666 commented 2 years ago

What was the error

rx570gtx1060 commented 2 years ago

const playlist = await getYoutubePlaylist(url); ^^^^^

SyntaxError: await is only valid in async functions and the top level bodies of modules at Object.compileFunction (node:vm:352:18) at wrapSafe (node:internal/modules/cjs/loader:1026:15) at Module._compile (node:internal/modules/cjs/loader:1061:27) at Object.Module._extensions..js (node:internal/modules/cjs/loader:1149:10) at Module.load (node:internal/modules/cjs/loader:975:32) at Function.Module._load (node:internal/modules/cjs/loader:822:12) at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12) at node:internal/main/run_main_module:17:47

haidang666 commented 2 years ago

if you want to use await at top level, you need node 16. Try this instead

getYoutubePlaylist(URL).then(playlist => console.log(playlist));