im having problems importing code from a file into the index.js file how do i fix it?
so you have to go to package.json
and add a value called "type": "module"
how to i add the value to package.js?
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.
i always have hidden files on but im wondering do i add it like this? “saycommand.js”:“module”
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';
just add "type": "module"
that’s it
it just says cannot use import statement outside a module
you
need
to add
"type": "module"
to package.json
replace “type” with the file?
You can use require("./sayCommand.js");
and assign it into a variable.
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
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?
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?