SyntaxError: Unexpected token ... in node.js - node.js

I have syntax error:
(unexpected token "...") in line config.db.database;
This is code in file.
odas_web-0.2-alpha/node_modules/electron-rebuild/lib/src/rebuild.js:81
depKeys.push(...Object.keys(rootPackageJson.dependencies || {}));
SyntaxError: Unexpected token ...
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:374:25)
at Object.Module._extensions..js (module.js:417:10)
at Module.load (module.js:344:32)
at Function.Module._load (module.js:301:12)
at Module.require (module.js:354:17)
at require (internal/module.js:12:17)
at Object.<anonymous> (/home/zhaohe/down/odas_web-0.2-alpha/node_modules/electron-rebuild/lib/src/cli.js:17:19)
at Module._compile (module.js:410:26)
at Object.Module._extensions..js (module.js:417:10)

You are using the spread/rest syntax ..., but the version of node you are running doesn't support it. Recommendation: upgrade to Node 10. If you use the newest version of the language, you don't have to play the game of "can I use this syntax?"

Related

npm will not respond at all

no matter what npm package I have, or try and install I keep getting this weird syntax error.
Users/BenNolan/.node/lib/node_modules/npm/lib/cli.js:66
module.exports = async process => {
^^^^^^^
SyntaxError: Unexpected identifier
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:414:25)
at Object.Module._extensions..js (module.js:442:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:311:12)
at Module.require (module.js:366:17)
at require (module.js:385:17)
at Object.<anonymous> (/Users/BenNolan/.node/lib/node_modules/npm/bin/npm-cli.js:2:1)
at Module._compile (module.js:435:26)
at Object.Module._extensions..js (module.js:442:10)
I have tried updating nvm, npm and node no matter what I try I am still getting the syntax error halfway through the install.

CircleCI fails at the fs-extra node_modules

I have been working on a project and recently, in Circle CI pipelines, I started to get this error.
/root/project/node_modules/fs-extra/lib/mkdirs/make-dir.js:85
} catch {
^
SyntaxError: Unexpected token {
at createScript (vm.js:80:10)
at Object.runInThisContext (vm.js:139:10)
at Module._compile (module.js:617:28)
at Object.Module._extensions..js (module.js:664:10)
at Module.load (module.js:566:32)
at tryModuleLoad (module.js:506:12)
at Function.Module._load (module.js:498:3)
at Module.require (module.js:597:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/root/project/node_modules/fs-extra/lib/mkdirs/index.js:3:44)
at Module._compile (module.js:653:30)
at Object.Module._extensions..js (module.js:664:10)
at Module.load (module.js:566:32)
at tryModuleLoad (module.js:506:12)
at Function.Module._load (module.js:498:3)
at Module.require (module.js:597:17)
I see some discussions about it online.
https://github.com/google/docsy/issues/265
https://www.gitmemory.com/issue/jprichardson/node-fs-extra/790/614647362
The nodejs version is 12.16.1
The fs-extra version is 9.0.1, in the cases, it was mentioned as ^9.0.0.
Does anyone know where this error comes from, and how to fix it? It seems like I am aligned with my node version (over v10) and the fs-extra. I prefer not to downgrade unless it is the only solution atm.

Gulp SintaxError : Unexpected identifier

I try to edit a Gulp app on my local server.
I thought it could something with ES6 or version, but I tried so hard and nothing.
I always have this error:
/var/www/html/carros/gulpfile.js:11
let dev = true;
^^^
SyntaxError: Unexpected identifier
at Module._compile (module.js:439:25)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Liftoff.handleArguments (/usr/local/lib/node_modules/gulp/bin/gulp.js:116:3)
at Liftoff.<anonymous> (/usr/local/lib/node_modules/gulp/node_modules/liftoff/index.js:198:16)
at module.exports (/usr/local/lib/node_modules/gulp/node_modules/liftoff/node_modules/flagged-respawn/index.js:17:3)
at Liftoff.<anonymous> (/usr/local/lib/node_modules/gulp/node_modules/liftoff/index.js:190:9)

Parse dashboard error

I successfully installed parse dashboard using the commands on the github repo.
When I try to run it from the command line I get the following error
/usr/local/lib/node_modules/parse-dashboard/Parse-Dashboard/index.js:10
const path = require('path');
^^^^^
SyntaxError: Use of const in strict mode.
at exports.runInThisContext (vm.js:73:16)
at Module._compile (module.js:443:25)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at Object.<anonymous> (/usr/local/lib/node_modules/parse-dashboard/bin/parse-dashboard:2:1)
at Module._compile (module.js:460:26)
at Object.Module._extensions..js (module.js:478:10)
Any one have any idea of what is going on here and how I can fix it?

understanding node.js error message

Error initializing middleware
SyntaxError: Unexpected token ILLEGAL
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:387:25)
at Object.Module._extensions..js (module.js:422:10)
at Module.load (module.js:357:32)
at Function.Module._load (module.js:314:12)
at Function.cls_wrapMethod [as _load] node_modules/newrelic/lib/shimmer.js:246:38)
at Module.require (module.js:367:17)
at require (internal/module.js:20:19)
at Object.<anonymous> api/services/chargeService.js:3:23)
at Module._compile (module.js:413:34)
at Object.Module._extensions..js (module.js:422:10)
at Module.load (module.js:357:32)
at Function.Module._load (module.js:314:12)
at Function.cls_wrapMethod [as _load] node_modules/newrelic/lib/shimmer.js:246:38)
at Module.require (module.js:367:17)
at require (internal/module.js:20:19)
Unexpected token ILLEGAL seems I made a typo or forgot to comment out a line in one of my source files. but the error message is very unhelpful.
is there any generic tools for parsing messages like this?
This is callstack
Error initializing middleware <== graceful error message
SyntaxError: Unexpected token ILLEGAL <== raw error message
at exports.runInThisContext (vm.js:53:16) <== YOUR SCRIPT, CHECK HERE
at Module._compile (module.js:387:25) <== node script
at Object.Module._extensions.js (module.js) <== node script
at Module.load (module.js:357:32) <== node script
at Function.Module._load (module.js:314:12) <== node script
at Function.cls node_modules/.../shimmer.js) <== package script
at Module.require (module.js:367:17) <== node script
at require (internal/module.js:20:19) <== node script
at Object.<anonymous> api/services/chargeService.js:3:23) <== YOUR SCRIPT, CHECK HERE
at Module._compile (module.js:413:34) <== node script, etc
at Object.Module._extensions..js (module.js:422:10)
at Module.load (module.js:357:32)
at Function.Module._load (module.js:314:12)
at Function.cls_wrapMethod [as _load] node_modules/newrelic/lib/shimmer.js:246:38)
at Module.require (module.js:367:17)
at require (internal/module.js:20:19)
Usually node scripts and npm packages don't throw unexpected exceptions, they have tests, so first of all you have to check your files
at exports.runInThisContext (vm.js:53:16)
This means exports.runInThisContext function in file vm.js was executed previously exception catched
at Object.<anonymous> api/services/chargeService.js:3:23)
Same as above, object getter or setter was executed in file chargeService at line 3 column 23 before exception catched

Resources