Firstly, I am very to the world or Node.js etc so apologies if this is an obvious problem.
I am creating a custom packages with a few components:
One component for example is this?
class MailProcess {
constructor(name, code) {
this.name = name;
this.code = code;
}
}
module.exports = {MailProcess: MailProcess};
and in my index file:
export {MailProcess} from "./mail/MailProcess";
// export more components like above
and my json file:
{
"name": "packagename",
"version": "1.0.3",
"description": "Private package",
"main": "index.js",
"publishConfig": {
"registry": "https://npm.pkg.github.com/...."
},
"scripts": {
"start": "node index.js"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"aws-sdk": "^2.1172.0",
"mysql": "^2.18.1"
}
}
and in my Main code I (after installing the above package) I implement like this:
let {MailProcess} = require('@myusername/mypackagename');
but the error get thrown of
SyntaxError: Unexpected token 'export' relating to the index file.
I am wondering what I might be doing wrong. Essentially my pack contains a few different classes and I try to export them in index so the code using this package has access
Thanks for any help