NodeJS Error In Constructor Language Only Present On Ubuntu - node.js

I am trying to get a particular npm package to run on Ubuntu 16.04. I am currently running the most up-to-date versions of nodejs and npm, as well as the package (turndown).
Here is the error that I get:
root#ubuntu-s-1vcpu-1gb-nyc1-01:/usr/server# nodejs index.js
/usr/server/node_modules/jsdom/lib/api.js:10
const { URL } = require("whatwg-url");
^
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 createHTMLParser (/usr/server/node_modules/turndown/lib/turndown.cjs.js:529:17)
at Object.<anonymous> (/usr/server/node_modules/turndown/lib/turndown.cjs.js:537:60)
at Module._compile (module.js:410:26)
The error states it occurs within the "turndown" package and is due to the language in the constructor. What is confusing to me is that this runs on Fedora 27 without error.
What could be causing the difference in behavior?

The answer to this question was to update my version of NodeJS. I ran into another error now, but it is package related.

Related

Why can't I use cdk on wsl2?

I installed cdk on wsl2 and I try to use it but I get this error:
(manifest,filePath,ASSETS_SCHEMA,Manifest.patchStackTagsOnRead)}static loadAssetManifest(filePath){return this.loadManifest(filePath,ASSETS_SCHEMA)}static saveIntegManifest(manifest,filePath){Manifest.saveManifest(manifest,filePath,INTEG_SCHEMA)}static loadIntegManifest(filePath){return this.loadManifest(filePath,INTEG_SCHEMA)}static version(){return SCHEMA_VERSION}static save(manifest,filePath){return this.saveAssemblyManifest(manifest,filePath)}static load(filePath){return this.loadAssemblyManifest(filePath)}static validate(manifest,schema4,options){function parseVersion(version){const ver=semver.valid(version);if(!ver){throw new Error(`Invalid semver string: "${version}"`)}return ver}const maxSupported=parseVersion(Manifest.version());const actual=parseVersion(manifest.version);if(semver.gt(actual,maxSupported)&&!(options==null?void 0:options.skipVersionCheck)){throw new Error(`${VERSION_MISMATCH}: Maximum schema version supported is ${maxSupported}, but found ${actual}`)}const validator=new jsonschema.Validator;const result=validator.validate(manifest,schema4,{nestedErrors:true,allowUnknownAttributes:false});let errors=result.errors;if(options==null?void 0:options.skipEnumCheck){errors=stripEnumErrors(errors)}if(errors.length>0){throw new Error(`Invalid assembly manifest:
SyntaxError: Unexpected token '?'
at wrapSafe (internal/modules/cjs/loader.js:915:16)
at Module._compile (internal/modules/cjs/loader.js:963:27)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
at Module.load (internal/modules/cjs/loader.js:863:32)
at Function.Module._load (internal/modules/cjs/loader.js:708:14)
at Module.require (internal/modules/cjs/loader.js:887:19)
at require (internal/modules/cjs/helpers.js:74:18)
at Object.<anonymous> (/usr/local/lib/node_modules/aws-cdk/bin/cdk.js:3:15)
at Module._compile (internal/modules/cjs/loader.js:999:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
I've tried reinstalling it, updating it, but I didn't succeed. I also searched on stack overflow but I didn't find anything to help me.
This was a problem in Node v12. Upgrading the version to v14 or higher should solve the problem.

Installation problems with CodeceptJS on Ubuntu

I was settings up a new system to use CodeceptJS and have hit an issue. I followed these notes, but just get an error when trying to run codeceptjs. The error is...
codeceptjs
/usr/local/lib/node_modules/codeceptjs-webdriverio/node_modules/codeceptjs/lib/mocha_factory.js:6
let mocha;
^^^
SyntaxError: Block-scoped declarations (let, const, function, class) not yet supported outside strict mode
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:373:25)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
at Object.<anonymous> (/usr/local/lib/node_modules/codeceptjs-webdriverio/node_modules/codeceptjs/lib/container.js:5:20)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
My node.js and npm is installed globally via normal apt-get and npm -g
System info...
Ubuntu 17.04 x86_64
nodejs: 4.7.2
npm: 4.5.0
bash 4.4.5
Does anyone know the cause of this issue or how to get around it?
Just as an update, thanks to artem for the note on 'use strict'; I added that to the top of node_modules/codeceptjs/lib/mocha_factory.js and that, I think, got me past the initial problem. However I now seem to be hitting an issue in node_modules/codeceptjs/lib/output.js. The error is...
codeceptjs
/usr/local/lib/node_modules/codeceptjs-nightmare/node_modules/codeceptjs/lib/output.js:139
function print(...msg) {
^^^
SyntaxError: Unexpected token ...
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:373:25)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
at Object.<anonymous> (/usr/local/lib/node_modules/codeceptjs-nightmare/node_modules/codeceptjs/lib/event.js:3:11)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
...I've tried a few things to resolve this, adjusting the print function there, but with no luck yet.
This seems to be the same with the codeceptjs-nightmare and codeceptjs-webdriverio meta-packages.
I'd be grateful of any ideas, suggestions or alternatives anyone has.
Your second issue is because of an outdated Node version. The spread operator (the ... error that you're seeing) is supported in Node 5.12.0 and later: http://node.green/#ES2015-syntax-spread-------operator
I'm not sure what the best way for you to upgrade is with Ubuntu, but that should solve your issue.

Getting: Error from phantom after upgrading to Node 6

after upgrading a MEAN stack application from 0.12 to node 6 we get the following error in our process.error log:
package/node_modules/phantom/lib/index.js:23 return new Promise(resolve => resolve(new _phantom2.default(args, config)));
and the process.output shows:
[2016-12-17 16:11:31.785] [ERROR] console - SyntaxError: Unexpected token >
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)
my version of phantomjs 1.9.8
this is the same problem reported previously:
phantomjs unexpected token
by some other user, but me being a relative newbie, I did not understand the answer or how it helps me fix the problem.
please direct me to a solution to this problem
This failure can be eliminated by using phantom versions prior to 2.0.0.
Notice that this is the phantom package and not the phantomjs package that is giving the error

nodejs SyntaxError: Unexpected token

I am using elasticsearch-exporter to export data from Elasticsearch.
The tool initially is a nodejs application.
When I try to use the following command node exporter.js to make the tool list all the available options, it crashes with the following exception
/home/me/storage/Elasticsearch-Exporter/log.js:54
exports.error = (...args) => !capture("ERROR", args) && console.log(timestamp() + util.format(...args).red);
^^^
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/anas/storage/Elasticsearch-Exporter/exporter.js:9:11)
at Module._compile (module.js:410:26)
at Object.Module._extensions..js (module.js:417:10)
here is the line where the exception is thrown
exports.error = (...args) => !capture("ERROR", args) && console.log(timestamp() + util.format(...args).red);
I think the error is related to a different version of nodejs but I am not sure.
Here is the output of the node --version command v4.2.6
Here is the output of the npm --version command 3.10.6
Yes, indeed, ... is called the spread operator and is only available since Node.js 6
The elasticsearch-exporter project declares in its package.json file that it only works with node version > 6
So since you're running Node.js 4.2.6, you either need to upgrade your Node.js installation or fork the elasticsearch-exporter project and modify it to work with Node.js 4.2.6.

unable to install meanjs on linux mint

it has been one week now that i was trying to install meanjs stack and had no success.
Everytime I follow some tutorial and get errors. Now I end up with many issues, too much nodejs version, i dont know which one should be with what and why do karma not working ...etc
is there anyway to remove everything and install meanjs correctly and get it running successfully
+ WARNING: It is strongly recommended that you change sessionSecret config while running in production!
Please add `sessionSecret: process.env.SESSION_SECRET || 'super amazing secret'` to
`config/env/production.js` or `config/env/local.js`
/opt/mean/node_modules/connect-mongo/src/index.js:3
const Promise = require('bluebird');
^^^^^
error: uncaughtException: Use of const in strict mode. date=Mon Jul 18 2016 19:15:59 GMT+0400 (GST), pid=29602, uid=1000, gid=1000, cwd=/opt/mean, execPath=/usr/local/bin/node, version=v0.10.33, argv=[node, /opt/mean/server], rss=47960064, heapTotal=35267072, heapUsed=18951416, loadavg=[0.5966796875, 0.453125, 0.66748046875], uptime=4058.491096953
SyntaxError: Use of const in strict mode.
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 Object. (/opt/mean/node_modules/connect-mongo/index.js:1:80)
at Module._compile (module.js:456:26)
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 Object. (/opt/mean/config/lib/express.js:12:16)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
below is my system config
Linux Mint 17.2 64-bit
NodeJS v0.10.33
npm 1.4.28
bower 1.7.9
mongodb v3.0.12
Can anyone please help me, I want to get started.
I haven't dug into it, but I'm guessing the version of node you have doesn't support the 'const' keyword. 0.10.x is a (fairly) old version of node; have you considered upgrading to one of the versions that has ES 6 native support?

Resources