understanding node.js error message - node.js

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

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.

SyntaxError: Unexpected token ... in 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?"

TypeError: Cannot use 'in' operator to search for '$__firebase' in undefined

I'm getting an error importing the Firebase npm module with an app hosted by OpenShift.
The following line
firebase = require('firebase/app'),
produces the following output in the log file
TypeError: Cannot use 'in' operator to search for '$__firebase' in undefined at /var/lib/openshift/57408de67628e1e65b00006a/app-root/runtime/repo/node_modules/firebase/app-node.js:19:449
at Object.<anonymous> (/var/lib/openshift/57408de67628e1e65b00006a/approot/runtime/repo/node_modules/firebase/app-node.js:19:617)
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 Module.require (module.js:367:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/var/lib/openshift/57408de67628e1e65b00006a/app-root/runtime/repo/node_modules/firebase/firebase-node.js:8:18)
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 Module.require (module.js:367:17)
at require (internal/module.js:20:19)
at /var/lib/openshift/57408de67628e1e65b00006a/app-root/runtime/repo/app.js:12:20
The strange thing is that if I execute
$ node app.js
there is no error and the app runs fine.
Try removing the --use-strict option in package.json, if you are using the cartridge with start.js and cluster.
See this stackoverflow q&a for more details on strict mode: in-node-js-how-the-use-strict-statement-is-interpreted
Hope it helps!

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?

rawmemchr: symbol not found in nodegit with docker

When I run the server in the Docker container, everything works fine until I include the line nodegit = require 'nodegit'. If NodeGit is required, on docker-compose up I get the following error:
Error: Error relocating
/usr/myContainer/node_modules/nodegit/build/Release/nodegit.node:
__rawmemchr: symbol not found
I tried NodeGit v.0.12.1 (the latest version) and v.0.11.0.
Without Docker, NodeGit works fine in the same project.
I am new to Docker and virtual machines generally. Any advice on how to troubleshoot this would really help. Thanks!
Update: here are the logs of my container:
[00:22:03] Requiring external module coffee-script/register
[00:22:04] Using gulpfile /usr/lada/gulpfile.coffee
[00:22:04] Starting 'lada-up'...
[00:22:04] Finished 'lada-up' after 23 ms
livereload[tiny-lr] listening on 35729 ...
Error: Error relocating /usr/lada/node_modules/nodegit/build/Release/nodegit.node: __rawmemchr: symbol not found
at Error (native)
at Object.Module._extensions..node (module.js:440:18)
at Module.load (/usr/lib/node_modules/coffee-script/lib/coffee-script/register.js:45:36)
at Function.Module._load (module.js:314:12)
at Module.require (module.js:367:17)
at require (internal/module.js:16:19)
at Object.<anonymous> (/usr/lada/node_modules/nodegit/lib/nodegit.js:9:12)
at Module._compile (module.js:413:34)
at Object.Module._extensions..js (module.js:422:10)
at Module.load (/usr/lib/node_modules/coffee-script/lib/coffee-script/register.js:45:36)
at Function.Module._load (module.js:314:12)
at Module.require (module.js:367:17)
at require (internal/module.js:16:19)
at Object.<anonymous> (/usr/lada/app/post.coffee:1:11)
at Object.<anonymous> (/usr/lada/app/post.coffee:1:1)
at Module._compile (module.js:413:34)
at Object.loadFile (/usr/lib/node_modules/coffee-script/lib/coffee-script/register.js:16:19)
at Module.load (/usr/lib/node_modules/coffee-script/lib/coffee-script/register.js:45:36)
at Function.Module._load (module.js:314:12)
at Module.require (module.js:367:17)
at require (internal/module.js:16:19)
at Object.<anonymous> (/usr/lada/app/index.coffee:8:6)
at Object.<anonymous> (/usr/lada/app/index.coffee:1:1)
at Module._compile (module.js:413:34)
at Object.exports.run (/usr/lib/node_modules/coffee-script/lib/coffee-script/coffee-script.js:134:23)
at compileScript (/usr/lib/node_modules/coffee-script/lib/coffee-script/command.js:224:29)
at compilePath (/usr/lib/node_modules/coffee-script/lib/coffee-script/command.js:174:14)
at Object.exports.run (/usr/lib/node_modules/coffee-script/lib/coffee-script/command.js:98:20)
at Object.<anonymous> (/usr/lib/node_modules/coffee-script/bin/coffee:7:41)
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.Module.runMain (module.js:447:10)
at startup (node.js:142:18)
at node.js:939:3

Resources