Javier
Javier

Reputation: 2095

eslint SyntaxError: Invalid regular expression flags

First of all, give thanks for reading my question and try to help me and apologize for my English.

I have a problem when deploying in jenkins.

When I try to deploy it shows me the following error:

[32mInstall complete.
[39m(node:41590) [DEP0026] DeprecationWarning: util.print is deprecated. Use console.log instead.
/var/lib/jenkins/workspace/DESIGNER DEV/node_modules/eslint/lib/source-code/source-code.js:426
        return /\s/u.test(text.replace(/\/\*.*?\*\//gus, ""));
                                       ^

SyntaxError: Invalid regular expression flags
    at createScript (vm.js:80:10)
    at Object.runInThisContext (vm.js:139:10)
    at Module._compile (module.js:599:28)
    at Object.Module._extensions..js (module.js:646:10)
    at Module.load (module.js:554:32)
    at tryModuleLoad (module.js:497:12)
    at Function.Module._load (module.js:489:3)
    at Module.require (module.js:579:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/var/lib/jenkins/workspace/DESIGNER DEV/node_modules/eslint/lib/source-code/index.js:4:17)
    at Module._compile (module.js:635:30)
    at Object.Module._extensions..js (module.js:646:10)
    at Module.load (module.js:554:32)
    at tryModuleLoad (module.js:497:12)
    at Function.Module._load (module.js:489:3)
    at Module.require (module.js:579:17)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] build: `fontello-cli install --config ./src/styles/components/icons/config.json --css  ./src/styles/components/icons/css --font  ./src/styles/components/icons/font && mkdir -p ./build && babel ./src/service-worker-designer.js --out-file ./build/service-worker-designer.js && react-scripts build`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

From what I've been looking at it is seen that it is a problem of the eslint version.

Could anyone tell me exactly what to do to fix it and be able to deploy in jenkins?

EDIT: (SOLUTION)

First, I've install svgo: npm install [email protected] -E

And Last, I updated jenkins node version to 8.10

Upvotes: 2

Views: 8633

Answers (4)

albin
albin

Reputation: 655

I had this problem because my node version was too old (8.9.1). Updating node resolved the issue.

Upvotes: 0

Sulaiman Abiodun
Sulaiman Abiodun

Reputation: 506

In my case (node react app), the cause of this error is the depreciated eslint-config-airbnb npm module. Running npx install-peerdeps --dev eslint-config-airbnb for npm 5+ works for me. Depending on the version of your npm, if your npm version is <5 then run npm install -g install-peerdeps install-peerdeps --dev eslint-config-airbnb. Hope this help?

Upvotes: 2

ss ulrey
ss ulrey

Reputation: 310

this worked around the issue for me...

In the v4.19.1, I experienced the same error from the file and line at /lib/source-code/source-code.js:426

The return statement of the function isSpaceBetweenTokens on the return line the following code return /\s/u.test(text.replace(/\/\*.*?\*\//gus, "")); should be return /\s/u.test(text.replace(/\/\*.*?\*\//, "gus"));

This solved the problem for me but the function in the most recent src seems to be depreciated.

Source: https://github.com/eslint/eslint/issues/12538#issuecomment-552734464

Upvotes: -1

Destin McMurry
Destin McMurry

Reputation: 29

Have you tried using a version of node >= 8.10?

Check this possibly related issue: https://github.com/eslint/eslint/issues/12493

Upvotes: 1

Related Questions