Anamik Adhikary
Anamik Adhikary

Reputation: 451

Angular universal installation throws error

While I try to install Angular Universal using the following command, I get errors:

command used:

     ng add @ng-toolkit/universal

Error:

       Invalid regular expression flags
         C:\Users\nnnn\Downloads\ccc\ngseo\node_modules\@ng- 
         toolkit\universal\schematics.js:199
        tree.overwrite(`/${options.serverFileName}`, 
        test_1.getFileContent(tree, 
        `/${options.serverFileName}`).replace(/\/\/ Start up the Node 
        server.*/gs, '').replace('const app = express();', 'export const 
        app = express();'));

        ^

   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 new ExportStringRef 
   (C:\Users\nnnn\Downloads\ccc\ngseo\node_modules\@angular- 
   devkit\schematics\tools\export-ref.js:18:25)
   at NodeModulesEngineHost._resolveReferenceString 
  (C:\Users\nnnn\Downloads\ccc\ngseo\node_modules\@angular- 
  devkit\schematics\tools\node-module-engine-host.js:94:21)
   at NodeModulesEngineHost.createSchematicDescription 
   (C:\Users\nnnn\Downloads\ccc\ngseo\node_modules\@angular- 
   devkit\schematics\tools\file-system-engine-host-base.js:172:34)
   at SchematicEngine.createSchematic 
   (C:\Users\nnnn\Downloads\ccc\ngseo\node_modules\@angular- 
   devkit\schematics\src\engine\engine.js:219:38)
    at CollectionImpl.createSchematic 
  (C:\Users\nnnn\Downloads\ccc\ngseo\node_modules\@angular- 
  devkit\schematics\src\engine\engine.js:69:29)
   at AddCommand.getSchematic 

(C:\Users\nnnn\Downloads\ccc\ngseo\node_modules@angular\cli\models\schematic-command.js:130:27) at AddCommand.runSchematic (C:\Users\nnnn\Downloads\ccc\ngseo\node_modules@angular\cli\models\schematic-command.js:262:32)

Do you have any idea how to resolve this?

Upvotes: 0

Views: 423

Answers (1)

Reactgular
Reactgular

Reputation: 54821

It's a known issue with the library.

https://github.com/maciejtreder/ng-toolkit/issues/590

You have to run a version of NodeJS that supports JavaScript ES2018.

http://2ality.com/2017/07/regexp-dotall-flag.html

Upgrade your NodeJS to the latest LTS version.

https://nodejs.org/en/

Upvotes: 1

Related Questions