I am more familiar using require() to load CommonJS files into my code. A library I am trying to use requires .mjs file so I am trying to get it to work. I thought it was relatively straight forward but I ran into an issue that I don't know what it is to even search it up.
In my GoogleHomeNotification.js file I have my app defined with 3 seperate functions. Within the same file
App.broadcast("Broadcasting a message");
or any other .js file I can use
const ax = require("../objects/GoogleHomeNotification.js");
ax.broadcast("Test");
Now in my test.mjs file I have
import * as GoogleNotification from "../objects/GoogleHomeNotification.js"
GoogleNotification.broadcast("Test");
and when I try to compile and run it, I get
TypeError: GoogleNotification.broadcast is not a function.
A nudge in the right direction of what I should be learning/searching for would be greatly appreciated!
GoogleHomeNotification.js:
var App = {
playin: false,
DeviceIp: "",
OriginalVolume: .5,
Player: null,
GoogleHome: function (host, url, callback) {},
run: function (ip, text) {},
broadcast: function(text){}
};
module.exports = App;
EDIT: Node version 14.15.4
importjust have been a synonym forrequirein the interim. :( The .mjs thing bytes my bits.