import not working in node
When I use
import, it gives an error. Does anyone know what's wrong and how I can fix it?
it's not in a cjs file
anyways, import requires some configuration, so in your package.json (maybe use
npm init -y to add?) add:
oh not to mention you never even exported the functions silly
I see you have the require syntax in your code, but is there a particular reason that you feel you need to use import syntax?
I made a fork of your repl that uses the standard export syntax and changed the filename to ".js" instead of ".cjs" so that you can do an implicit require on the file, as well. The only extra line it needs is the
module.exports at the bottom that puts the
bye functions as exportable functions.