Universal Angular 4: getting SyntaxError while using ng2 nouislider - node.js

I am working on Universal Angular 4 project.
while adding "nouislider" in html file,i am getting the following error
import * as i0 from '#angular/core';
SyntaxError: Unexpected token import
at createScript (vm.js:74:10)
at Object.runInThisContext (vm.js:116:10)
at Module._compile (module.js:533:28)
at Module._extensions..js (module.js:580:10)
at Object.require.extensions.(anonymous function) [as .ts] (/home/user/Desktop//node_modules/ts-node/src/index.ts:384:14)
at Module.load (module.js:503:32)
at tryModuleLoad (module.js:466:12)
at Function.Module._load (module.js:458:3)
at Module.require (module.js:513:17)
at require (internal/module.js:11:18)
slider is working fine when i am working on angular 4 only i.e without server side rendering(SSR) but getting above error when doing SSR.
Please help me to get out of this.Thanks in Advance.

Related

Syntax error on "=" NodeJs in Ubuntu 20.04

I have developed a NodeJs(v10.19.0) server on windows.
I now need to transfer it to a linux server running Ubuntu 20.04
When I try to start the server, I have a syntax error on a "=".
Here's the complet error:
/puppeteer/scraping-bot.js:6
static websiteRegex = /^(https?\:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})(\/[\w\W]*)*$/gm
^
SyntaxError: Unexpected token =
at Module._compile (internal/modules/cjs/loader.js:723:23)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
at Module.require (internal/modules/cjs/loader.js:692:17)
at require (internal/modules/cjs/helpers.js:25:18)
at Object.<anonymous> (/routes/scraping.js:1:21)
at Module._compile (internal/modules/cjs/loader.js:778:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
[nodemon] app crashed - waiting for file changes before starting...
Here's the code that outputs the error:
class ScrapingBot {
static websiteRegex = /^(https?\:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})(\/[\w\W]*)*$/gm
static phoneRegex = /\+?\d{1,4}?[-.\s]?\(?\d{1,3}?\)?[-.\s]?\d{1,4}[-.\s]?\d{1,4}[-.\s]?\d{1,9}/g;
static addressRegex = /(([a-zA-Z-éÉèÈàÀùÙâÂêÊîÎôÔûÛïÏëËüÜçÇæœ'.]*\s)\d*(\s[a-zA-Z-éÉèÈàÀùÙâÂêÊîÎôÔûÛïÏëËüÜçÇæœ']*)*,)*\d*(\s[a-zA-Z-éÉèÈàÀùÙâÂêÊîÎôÔûÛïÏëËüÜçÇæœ']*)+,\s([\d]{5})\s[a-zA-Z-éÉèÈàÀùÙâÂêÊîÎôÔûÛïÏëËüÜçÇæœ']+/
...
}
I set up Git with nano if that helps...
I have already tried to replace the "=".
As you can see in here, static class fields are not supported as of Node 10 ->
https://node.green/#ES2022-features-static-class-fields
edit: #jonrsharpe also answered this

Node js script not starting up, async * Unexpected Token

I am trying to run my node script with node . on Ubuntu 18.04
It worked successfully on previous machine. This is a new setup and running into this error.
/var/www/html/node_bot/node_modules/discord.js/src/structures/interfaces/Collector.js:203
async *[Symbol.asyncIterator]() {
^
SyntaxError: Unexpected token *
at createScript (vm.js:80:10)
at Object.runInThisContext (vm.js:139:10)
at Module._compile (module.js:616:28)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/var/www/html/node_bot/node_modules/discord.js/src/structures/MessageCollector.js:3:19)
My node version is v8.10.0 on all accounts including root.
I have tried chowning the files to root and running from root, same error.
Am I missing a package or something? Thanks
Use a newer node version.
From library documentation
https://github.com/discordjs/discord.js
Installation
Node.js 10.2.0 or newer is required.
Updated to node v10.18.1 and it works.

Node.js SteamBot not working

my Node.js Steam-Bot isnt working. When i try starting him it always gives a Syntax Error:
/root/bot/node_modules/steam-tradeoffer-manager/lib/index.js:3
const SteamCommunity = require('steamcommunity');
^^^^^
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> (/root/bot/tradebot.js:20:25)
at Module._compile (module.js:460:26)
at Object.Module._extensions..js (module.js:478:10)
Iam using Debian 8, Node Version 0.12.
Thank you!
The error says it all. Replace const with var.
Also, you should update your nodeJS version as mentioned in the comments. This is really important.

Sails generate-oauth

I following this link sails-generate-oauth to generate oauth with sails, i follow and make all steps as in the refered page say but i am getting this error:
root#Ubuntu:~/sailTests/guatour# sails lift
info: Starting app...
/root/sailTests/guatour/config/routes.js:50
'get /login': 'AuthController.login',
^^^^^^^^^^^^
SyntaxError: Unexpected string
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 /usr/local/lib/node_modules/sails/node_modules/include- all/index.js:129:29
at Array.forEach (native)
at requireAll (/usr/local/lib/node_modules/sails/node_modules/include-all/index.js:44:9)
at buildDictionary (/root/sailTests/guatour/node_modules/sails/node_modules/sails-build-dictionary/index.js:68:14)
at Function.module.exports.aggregate (/root/sailTests/guatour/node_modules/sails/node_modules/sails-build-dictionary/index.js:190:9)
at Array.loadOtherConfigFiles (/root/sailTests/guatour/node_modules/sails/lib/hooks/moduleloader/index.js:164:27)
at /root/sailTests/guatour/node_modules/sails/node_modules/async/lib/async.js:484:38
at _each (/root/sailTests/guatour/node_modules/sails/node_modules/async/lib/async.js:46:13)
at Object.async.auto (/root/sailTests/guatour/node_modules/sails/node_modules/async/lib/async.js:455:9)
Am i missing something?
Thanks for your help, regards.
Sorry, i found my error, it was a coma, before the (/) route (default).

unexpected token <

Using the nodejs v.6.7 with faye v.7.1 I am getting error
/path/livestats/node_modules/faye0.7/faye.js:18
ID_LENGTH: <%= Faye::ID_LENGTH %>,
^
-----------------------
Exception: SyntaxError: Unexpected token <
SyntaxError: Unexpected token <
at Module._compile (module.js:427:25)
at Object..js (module.js:450:10)
at Module.load (module.js:351:31)
at Function._load (module.js:310:12)
at Module.require (module.js:357:17)
at require (module.js:368:17)
at Object.<anonymous> (/path/livestats/lib/livestats.js:4:12)
at Module._compile (module.js:432:26)
at Object..js (module.js:450:10)
at Module.load (module.js:351:31)
-----------------------
I am trying to implement example showing in peepcode's Meet node.js video.
Seems like you requiring faye.js as is before building faye_node.
You need to follow instructions on faye repository or installing it via npm:
npm install faye -d
If you install it via NPM you can require("faye-node")

Resources