【问题标题】:ng command giving error, SyntaxError: Unexpected token ). centos 7ng 命令给出错误,SyntaxError: Unexpected token )。 7
【发布时间】:2020-06-02 03:17:57
【问题描述】:

在通过 ng -v 检查 angular-cli 的版本时,我在 centOs7 服务器上遇到了问题。 我得到如下输出:

/usr/lib/node_modules/@angular/cli/bin/ng:23
  );
  ^
SyntaxError: Unexpected token )
    at createScript (vm.js:56:10)
    at Object.runInThisContext (vm.js:97:10)
    at Module._compile (module.js:549:28)
    at Object.Module._extensions..js (module.js:586:10)
    at Module.load (module.js:494:32)
    at tryModuleLoad (module.js:453:12)
    at Function.Module._load (module.js:445:3)
    at Module.runMain (module.js:611:10)
    at run (bootstrap_node.js:394:7)
    at startup (bootstrap_node.js:160:9)

即使因为这个问题而无法构建项目,我正在使用 Jenkins 进行构建。

【问题讨论】:

    标签: angular angular-cli ng-build


    【解决方案1】:

    要解决此问题, 我执行了以下步骤:

    1. sudo vi /usr/lib/node_modules/@angular/cli/bin/ng

    2. 找到语法,

    var version = process.versions.node.split('.').map(part => Number(part));
    if (version[0] < 10 || version[0] === 11 || (version[0] === 10 && version[1] < 13)) {
      process.stderr.write(
        'Node.js version ' + process.version + ' detected.\n' +
        'The Angular CLI requires a minimum Node.js version of either v10.13 or v12.0.\n\n' +
        'Please update your Node.js version or visit https://nodejs.org/ for additional instructions.\n',
      );
    }
    
    1. 删除\n后多余的逗号(,)
    2. 保存文件并退出

    这将解决问题。 我希望这会有所帮助。

    【讨论】:

      猜你喜欢
      • 2018-08-22
      • 2015-09-17
      • 2017-05-02
      • 2016-10-01
      • 1970-01-01
      • 1970-01-01
      • 2020-08-18
      • 2015-04-21
      • 1970-01-01
      相关资源
      最近更新 更多