角度通用安装会引发错误

问题描述 投票:0回答:1

当我尝试使用以下命令安装Angular Universal时,我收到错误:

使用的命令:

     ng add @ng-toolkit/universal

错误:

       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)在AddCommand.runSchematic(C:\ Users \ nnnn \ Downloads \ ccc \ ngseo \ node_modules @角\ CLI \模型\示意-command.js:262:32)

你知道如何解决这个问题吗?

angular angular-universal
1个回答
1
投票

这是图书馆的一个已知问题。

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

您必须运行支持JavaScript ES2018的NodeJS版本。

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

将NodeJS升级到最新的LTS版本。

https://nodejs.org/en/

© www.soinside.com 2019 - 2024. All rights reserved.