I have a nodejs app that I need to research but unfortunately it can not start. The employee left the company and did't left much info on the app so I'm kinda lost in here.
The app runs with pm2. When I execute "pm2 start ecosystem.json" the status is "online" for a couple of seconds and then changes to "errored".
In the log file from "pm2 desc ID" appears the following error.
SyntaxError: Invalid or unexpected token
at createScript (vm.js:80:10)
at Object.runInThisContext (vm.js:139:10)
at Module._compile (module.js:599:28)
at Object.Module._extensions..js (module.js:646:10)
at Module.load (module.js:554:32)
at tryModuleLoad (module.js:497:12)
at Function.Module._load (module.js:489:3)
at Object.<anonymous> (/usr/lib/node_modules/pm2/lib/ProcessContainerFork.js:83:21)
at Module._compile (module.js:635:30)
at Object.Module._extensions..js (module.js:646:10)
Here is the package.json
{
"name": "njs-data-api",
"version": "0.0.0",
"private": true,
"scripts": {
"watch": "NODE_ENV=development nodemon --exec babel-node -- ./bin/www",
"build": "rm -rf dist && babel src --ignore __tests__ --out-dir dist",
"sync": "copy the built files to staging",
"deploy": "npm run build && npm run sync",
"start": "NODE_ENV=staging node ./bin/www"
},
"dependencies": {
"bluebird": "^3.5.1",
"body-parser": "~1.18.2",
"bunyan": "^1.8.12",
"cookie-parser": "~1.4.3",
"debug": "~2.6.9",
"dotenv": "^4.0.0",
"express": "~4.15.5",
"joi": "^13.2.0",
"moment": "^2.22.1",
"morgan": "~1.9.0",
"pg": "^7.4.1",
"pg-promise": "^7.5.4",
"pg-pubsub": "^0.3.0",
"pm2": "^2.10.2",
"pug": "2.0.0-beta11",
"redis": "^2.8.0",
"serve-favicon": "~2.4.5"
},
"devDependencies": {
"babel-cli": "^6.26.0",
"babel-preset-es2015-node6": "^0.4.0",
"babel-preset-stage-0": "^6.24.1",
"colors": "^1.2.1",
"nodemon": "^1.17.3"
}
}
Any help on how to fix this error will be highly appreciated!
EDIT
this is the content of ecosystem.json
{
"apps": [
{
"name": "User Data Api",
"script": "./bin/www",
"watch": true,
"merge_logs": true,
"min_uptime": 4000,
"max_restarts": 50,
"log_date_format": "YYYY-MM-DD HH:mm:ss.SSS",
"env": {
}
}
]
}
When I run node ./bin/www I get the following error:
/mnt/c/ubuntu/nodejs/njs-user-data-api/bin/www:89 }
SyntaxError: Invalid or unexpected token
at createScript (vm.js:80:10)
at Object.runInThisContext (vm.js:139:10)
at Module._compile (module.js:599:28)
at Object.Module._extensions..js (module.js:646:10)
at Module.load (module.js:554:32)
at tryModuleLoad (module.js:497:12)
at Function.Module._load (module.js:489:3)
at Function.Module.runMain (module.js:676:10)
at startup (bootstrap_node.js:187:16)
at bootstrap_node.js:608:3
On line 89 is the closing curly brace of the last js function
Not sure about the root of the issue but I fixed it.
When I run node ./bin/www I get the following error:
/mnt/c/ubuntu/nodejs/njs-user-data-api/bin/www:89 }
This is the closing curly brace of very simple function at the end of the file. I noticed that when I try to move the marker/cursor of PHPStorm to the closing brace it was not possible and the IDE can not detect the opening brace. So I hit the backspace 5-6 times until the curly brace is deleted. When I typed a curly brace again then the IDE was able to detect the opening and closing curly braces and everything worked.
Anyone have an idea of what could be causing this issue?