Home > OS >  Syntax error on "=" NodeJs in Ubuntu 20.04
Syntax error on "=" NodeJs in Ubuntu 20.04

Time:06-17

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 "=".

CodePudding user response:

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

  • Related