I'm working on a API integration with the ES6 module system and jQuery. I want to use re-use my addToCart function, that is why I placed it into a separate file. But when calling it I get following error:
Uncaught SyntaxError: Export 'addToCart' is not defined in module
you should have the latest version of Node.js installed (or, at least 13.2.0+). Then do one of the following, as described in the documentation:
Option 1
In the nearest parent package.json file, add the top-level "type" field with a value of "module". This will ensure that all .js and .mjs files are interpreted as ES modules. You can interpret individual files as CommonJS by using the .cjs extension.
// package.json
Option 2
Explicitly name files with the .mjs extension. All other files, such as .js will be interpreted as CommonJS, which is the default if type is not defined in package.json.