【问题标题】:ng new fails with "SyntaxError: Unexpected token =" on Ubuntung new 在 Ubuntu 上因“SyntaxError: Unexpected token =”而失败
【发布时间】:2018-02-25 12:20:27
【问题描述】:

我使用的是 Ubuntu 16.04.3 LTS,我使用 sudo apt-get install npm node 安装了 npm 和 node。之后我安装了@angular/clisudo npm install @angular/cli -g

但是当我尝试使用ng new hello-world 创建一个新项目时,它会失败并出现以下错误:

/usr/local/lib/node_modules/@angular/cli/models/config/config.js:17
    constructor(_configPath, schema, configJson, fallbacks = []) {
                                                           ^

SyntaxError: Unexpected token =
    at exports.runInThisContext (vm.js:53:16)

如何使ng new 工作?

【问题讨论】:

    标签: node.js angular ubuntu


    【解决方案1】:

    原来是因为 Ubuntu 在 repos 中有一个旧版本的节点。我按照https://nodejs.org/en/download/package-manager/ 的说明安装了更新的版本,从而修复了该错误

    curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
    sudo apt-get install -y nodejs
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-06-27
      • 2022-06-16
      • 2018-03-29
      • 1970-01-01
      • 1970-01-01
      • 2020-12-28
      • 1970-01-01
      • 2017-12-06
      相关资源
      最近更新 更多