galnir / Master-Bot

A Discord music bot and dashboard with slash commands, playlist support, Spotify, music quiz, saved playlists, lyrics, gifs and more

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

SyntaxError: Cannot use import statement outside a module

QuantaNeon opened this issue · comments

I have successfully dont everything to host the bot upto npx prisma migrate dev command
finally when i do node indes.ts

/home/ubuntu/music/src/index.ts:1
import { load } from '@lavaclient/spotify';
^^^^^^

SyntaxError: Cannot use import statement outside a module
    at Object.compileFunction (node:vm:352:18)
    at wrapSafe (node:internal/modules/cjs/loader:1032:15)
    at Module._compile (node:internal/modules/cjs/loader:1067:27)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1157:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12)
    at node:internal/main/run_main_module:17:47

I am on ubuntu 20.04 vps
node version is azul 17

pleaze fill out the bug template as it helps us with understanding the issue

IMPORTANT : DO NOT SKIP THIS STEPS AND DO NOT DELETE THEM. WE CAN NOT HELP YOU IF YOU DO NOT PROVIDE INFORMATION AND STEPS TO REPRODUCE

Do not open an issue if you simply "copied" code over to your bot/another bot. This is absolutely not recommended and will cause bugs. Also do not open an issue if you modified code and added features and now it's not working right. This is because I can't figure it out and don't have the time to read your code and find out what you did wrong.

Describe the bug
A clear and concise description of what the bug is.

To Reproduce
Steps to reproduce the behavior:

  1. Use 'x' command
  2. provide 'y' argument

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: [e.g. Windows, Ubuntu...]:
  • Node.js Version(Should be v16 at least):
  • Is python 2.7 installed?:
  • How are you hosting the bot(Locally, on a vps, heroku, glitch...):

Additional context
Add any other context about the problem here.

you can try the following,
Lavalink make sure to run npm install then npm run build now open a second terminal and run java -jar LavaLink.jar before node /dis/index.js in a separate terminal

Hope this Helps
Much Love
-Bacon

uh...what exactly do u want me to do?
here is when i run with tsc

tsc index.ts
../node_modules/@lavaclient/spotify/index.d.ts:186:5 - error TS18028: Private identifiers are only available when targeting ECMAScript 2015 and higher.

186     #private;
        ~~~~~~~~

../node_modules/@lavaclient/spotify/index.d.ts:198:5 - error TS18028: Private identifiers are only available when targeting ECMAScript 2015 and higher.

198     #private;
        ~~~~~~~~

index.ts:8:23 - error TS2732: Cannot find module './config.json'. Consider using '--resolveJsonModule' to import module with '.json' extension.

8 import * as data from './config.json';
                        ~~~~~~~~~~~~~~~

structures/ExtendedClient.ts:4:23 - error TS2732: Cannot find module '../config.json'. Consider using '--resolveJsonModule' to import module with '.json' extension.

4 import * as data from '../config.json';
                        ~~~~~~~~~~~~~~~~


Found 4 errors in 3 files.

Errors  Files
     2  ../node_modules/@lavaclient/spotify/index.d.ts:186
     1  index.ts:8
     1  structures/ExtendedClient.ts:4

IDK what happened...but it seems to be working fine now ;-;

commented

IDK what happened...but it seems to be working fine now ;-;

You can't run TS files, they need to be compiled into JS files. You run the bot using npm run dev (all it does it compile the files to TS and runs the compiled index file)