angular - 通过 CLI 安装 Angular 2 后无法创建新实例

标签 angular angular-cli

我正在尝试使用 @Angular cli 创建一个新的 Angular 2 项目。安装进行得很顺利,但是当我尝试创建新站点时,出现以下错误。有人遇到过这种情况吗?

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

SyntaxError: Unexpected token =
    at exports.runInThisContext (vm.js:53:16)
    at Module._compile (module.js:387:25)
    at Object.Module._extensions..js (module.js:422:10)
    at Module.load (module.js:357:32)
    at Function.Module._load (module.js:314:12)
    at Module.require (module.js:367:17)
    at require (internal/module.js:16:19)
    at Object.<anonymous> (/usr/local/lib/node_modules/@angular/cli/models/config.js:2:18)
    at Module._compile (module.js:413:34)
    at Object.Module._extensions..js (module.js:422:10)

实际上,看起来@angular cli 没有安装。我无法获得 --version,当我查看安装结果时,我看到以下警告:

npm WARN @ngtools/<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="5a2d3f382a3b39311a6b74687463" rel="noreferrer noopener nofollow">[email protected]</a> requires a peer of @angular/compiler@^2.3.1 || >=4.0.0-beta <5.0.0 but none was installed.
npm WARN @ngtools/<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="166173746677757d56273824382f" rel="noreferrer noopener nofollow">[email protected]</a> requires a peer of @angular/compiler-cli@^2.3.1 || >=4.0.0-beta <5.0.0 but none was installed.
npm WARN @ngtools/<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="641301061405070f24554a564a5d" rel="noreferrer noopener nofollow">[email protected]</a> requires a peer of @angular/core@^2.3.1 || >=4.0.0-beta <5.0.0 but none was installed.
npm WARN @ngtools/<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="c2b5a7a0b2a3a1a982f3ecf0ecfb" rel="noreferrer noopener nofollow">[email protected]</a> requires a peer of @angular/tsc-wrapped@^0.5.0 but none was installed.

最佳答案

也许你的 Nodejs 版本已经过时了?确保您拥有最新的 LTS 6.x

关于angular - 通过 CLI 安装 Angular 2 后无法创建新实例,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42218055/

相关文章:

Angular CLI 自定义 webpack 配置

angular - 为 Angular 2 项目进行 ng Prod 构建时出错

angular - 如何在 Angular 6 中使用参数创建 observable?

javascript - RxJs:如何在接收到流时更改订阅的 "listen"?

angular - 有没有办法订阅部分 BehaviorSubject 值的变化?

node.js - 如何使用网络套接字和 Angular CLI 设置代理

javascript - 带有 TypeScript 错误的 Angular HTTP GET http.get(...).map 不是 [null] 中的函数

angular - 以 Angular 2 重置模板驱动的表单(模型和验证)

angular-cli - 用于生成类的类型选项的可能值

javascript - 扩展 Angular-CLI 构建过程