Nuxt.js: npm run dev returns Error - SyntaxError: Invalid regular expression flags

Created on 4 May 2019  路  7Comments  路  Source: nuxt/nuxt.js

Version

v2.4.0

Steps to reproduce

OS: MS Windows 10 Pro 64-bits
OS build: 10.0.17763
From scratch:

  1. create-nuxt-app app-nuxt
  2. cd app-nuxt
  3. npm run dev

    What is expected?

compile the application and start the dev server

What is actually happening?

app-nuxtnode_modules\@nuxt\utils\dist\utils.js:1752 const match = asString.match(/^([^{(]+)=>\s(.)/s);

SyntaxError: Invalid regular expression flags

at createScript (vm.js:80:10) at Object.runInThisContext (vm.js:139:10) at Module._compile (module.js:607:28) at Object.Module._extensions..js (module.js:654:10) at Module.load (module.js:556:32) at tryModuleLoad (module.js:499:12) at Function.Module._load (module.js:491:3) at Module.require (module.js:587:17) at require (internal/module.js:11:18) at Object. (D:\projectscompany_project\app-nuxtnode_modules\@nuxtcli\distcli-chunk.js:15:15) npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! [email protected] dev: nuxt npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the [email protected] dev script.

Additional comments

By tracking down the bug locally in node_modules\@nuxt\utils\dist\utils.js
on line 1752: const match = asString.match(/^([^{(]+)=>\s(.)/s);
line 1754: const fullFunctionBody = match[2].match(/^{?(\sreturn\s+)?(.?)}?$/s);
and line 1756: if (fullFunctionBody[1] || !match[2].trim().match(/^\s*{/s))
and removing the s flag from these three lines, npm run dev worked prefect.

This question is available on Nuxt community (#c9153)
available soon bug-report

Most helpful comment

I ran into the same issue with both the _nuxt_ and _nuxt generate_ commands.

OS: MS Windows 10 Pro 64-bits
Node version: 8.16

Upgrading to Node 10.15 fixed it for me.

All 7 comments

This issue as been imported as question since it does not respect nuxt.js issue template. Only bug reports and feature requests stays open to reduce maintainers workload.
If your issue is not a question, please mention the repo admin or moderator to change its type and it will be re-opened automatically.
Your question is available at https://cmty.app/nuxt/nuxt.js/issues/c9153.

What Node.js version do you use?

I ran into the same issue with both the _nuxt_ and _nuxt generate_ commands.

OS: MS Windows 10 Pro 64-bits
Node version: 8.16

Upgrading to Node 10.15 fixed it for me.

Should probably add

"engines": {
  "node": ">=10.0.0"
}

to your package.json

Fixed in #5608 , fix will be included in next release

Had same issue, upgrading node.js fixed it.

I have:

  • nuxtjs v2.10.2
  • OS Ubuntu
  • npm v6.12.0
  • node v10.15.3
    and, when running npm run generate I get SyntaxError: invalid regexp group.
    Instead, npm run dev works fine in my case!
    Does anyone have the same issue?
    I reported the issue here.
Was this page helpful?
0 / 5 - 0 ratings

Related issues

danieloprado picture danieloprado  路  3Comments

o-alexandrov picture o-alexandrov  路  3Comments

mikekidder picture mikekidder  路  3Comments

gary149 picture gary149  路  3Comments

vadimsg picture vadimsg  路  3Comments