Newbie question here. I have this problem using ESmodules.
SyntaxError: The requested module './esModules.js' does not provide an export named 'add'.
I do have the "Type": "modules" in my package.json
My code:
// index.js
import add from "./esModules.js";
let num1 = 15;
let num2 = 20;
console.log(add(num1, num2));
// esModules.js
export const add = (num1, num2) => {
result = num1 + num2;
};
I tried adding "export default add;" which I read somewhere,
I tried using { add } in the import sentence,
I tried without ".js" in the import sentence,
but it doesn´t work either.
Thanks!
EDIT:
Solution: It worked with { add } and adding the "return result" in the add function!