Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

399
Views
NodeJS: SyntaxError: Unexpected token 'export' when trying to create a node module package

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

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!