Import problems

im having problems importing code from a file into the index.js file how do i fix it?

1 Like

so you have to go to package.json and add a value called "type": "module"

how to i add the value to package.js?

1 Like

wdym, you just go to package.json like just add a json value

package.json. If you can’t see it (I think you can by default, but I’m not sure) turn on hidden files.

1 Like

i always have hidden files on but im wondering do i add it like this? “saycommand.js”:“module”

1 Like

keep in mind that when you do that, for module packages you have to do

import { ImportThing } from 'ImportPackage';

and if it’s not a module do

import ImportThing from 'ImportPackage';
1 Like

just add "type": "module" that’s it

1 Like

it just says cannot use import statement outside a module

1 Like

to add
"type": "module" to package.json

replace “type” with the file?

1 Like

You can use require("./sayCommand.js"); and assign it into a variable.

1 Like

can you just
do what I said first and then see if it works before fiddling with that

yeah except it’s a module os you need to do that sadly

thats what i did in the index.js file

edit: oh wait nvm

so it worked? please mark @savardo as solved (if his helped, if not then mark mine if it worked)

added it in and nothing worked

can you tell me what’s wrong? Remember I told you packages that aren’t modules ;-;

anything else not work?

1 Like

well smh worked but but now a new error about cmd.handler is not a function and also a quick error on startup that flashes

ok can you please add the error so I can see it?