Unitech / Unitech/pm2

SyntaxError: Unexpected token 'export'

Open
#5,136 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
43.3k
Forks
2.7k
PR merge metrics
No merged PRs in 30d

Description

What's going wrong?

export default class Tools {
^^^^^^

SyntaxError: Unexpected token 'export'
at Object.compileFunction (node:vm:352:18)
at wrapSafe (node:internal/modules/cjs/loader:1025:15)
at Module._compile (node:internal/modules/cjs/loader:1059:27)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1124:10)
at Module.load (node:internal/modules/cjs/loader:975:32)
at Function.Module._load (node:internal/modules/cjs/loader:816:12)
at Module.require (node:internal/modules/cjs/loader:999:19)
at Module.Hook._require.Module.require (/usr/local/lib/node_modules/pm2/node_modules/require-in-the-middle/index.js:80:39)
at require (node:internal/modules/cjs/helpers:93:18)
at Object. (/Users/rox/Projects/CrimeTimeApi/models/Case.js:4:15)

How could we reproduce this issue?

I have a class named Tools declared as

export default class Tools {
.
.
.
}

Supporting information

I can run the app alone without the -i max option but if i use the -i max option, it gives me the above stated error.

$ pm2 report

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the failure with the reported Tools class in models/Case.js and PM2's -i max option, then compare it with running the app without that option. Use the available pm2 report output to identify the relevant PM2 and Node.js versions; done means the same application starts successfully in both modes without the export syntax error.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, nodejs
Domain
cli, devops
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.