NG2似乎变化如此之快,以至于我无法再建立一个项目。几个小时以来一直在努力奋斗,似乎在无休止的循环中试图从我的项目中获得构建。
<nav class="navbar navbar-inverse">
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#myNavbar">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">WebSiteName</a>
</div>
<div class="collapse navbar-collapse" id="myNavbar">
<ul class="nav navbar-nav">
<li class="active"><a href="#">Home</a></li>
<li class="dropdown">
<a class="dropdown-toggle" data-toggle="dropdown" href="#">Page 1 <span class="caret"></span></a>
<ul class="dropdown-menu">
<li><a href="#">Page 1-1</a></li>
<li><a href="#">Page 1-2</a></li>
<li><a href="#">Page 1-3</a></li>
</ul>
</li>
<li><a href="#">Page 2</a></li>
<li><a href="#">Page 3</a></li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li><a href="#"><span class="glyphicon glyphicon-user"></span> Sign Up</a></li>
<li><a href="#"><span class="glyphicon glyphicon-log-in"></span> Login</a></li>
</ul>
</div>
</div>
</nav>
当我运行时:ng build我收到以下错误:
$ ng -v
@angular/cli: 1.0.0-rc.0
node: 7.4.0
os: darwin x64
@angular/common: 2.2.0
@angular/compiler: 2.2.0
@angular/core: 2.4.8
@angular/forms: 2.2.0
@angular/http: 2.2.0
@angular/platform-browser: 2.2.0
@angular/platform-browser-dynamic: 2.2.0
@angular/router: 3.2.0
@angular/cli: error
@angular/compiler-cli: error
所以我运行建议的命令并得到以下错误:
This version of CLI is only compatible with angular version 2.3.1 or better. Please
upgrade your angular version, e.g. by running:
npm install @angular/core@latest
所以看来我需要安装未满足的对等依赖项,所以:
> fsevents@1.1.1 install /path-to/node_modules/fsevents
> node install
[fsevents] Success: "/path-to/node_modules/fsevents/lib/binding/Release/node-v51-darwin-x64/fse.node" is installed via remote
app@0.1.0 /path-to/app-name
├── UNMET PEER DEPENDENCY @angular/core@2.4.8
├── UNMET PEER DEPENDENCY rxjs@5.0.0-beta.12 invalid
└── UNMET PEER DEPENDENCY zone.js@0.6.26 invalid
npm WARN @angular/common@2.2.0 requires a peer of @angular/core@2.2.0 but none was installed.
npm WARN @angular/compiler@2.2.0 requires a peer of @angular/core@2.2.0 but none was installed.
npm WARN @angular/core@2.4.8 requires a peer of rxjs@^5.0.1 but none was installed.
npm WARN @angular/core@2.4.8 requires a peer of zone.js@^0.7.2 but none was installed.
npm WARN @angular/forms@2.2.0 requires a peer of @angular/core@2.2.0 but none was installed.
npm WARN @angular/http@2.2.0 requires a peer of @angular/core@2.2.0 but none was installed.
npm WARN @angular/platform-browser@2.2.0 requires a peer of @angular/core@2.2.0 but none was installed.
npm WARN @angular/platform-browser-dynamic@2.2.0 requires a peer of @angular/core@2.2.0 but none was installed.
npm WARN @angular/router@3.2.0 requires a peer of @angular/core@2.2.0 but none was installed.
npm WARN @angular/upgrade@2.2.0 requires a peer of @angular/core@2.2.0 but none was installed.
npm WARN app-name@0.1.0 No description
npm WARN app-name@0.1.0 No repository field.
npm WARN app-name@0.1.0 No license field.
我走了......
这是我的package.json文件......
$npm install @angular/core rxjs zone.js
my-app@0.1.0 /path-to/app
├── @angular/core@2.2.0 invalid
├── rxjs@5.0.0-beta.12 invalid
└── zone.js@0.6.26 invalid
任何指导都将不胜感激......