AngularJS教程: http://angularjs.cn/A00a
学习到第七章时:AngularJS入门教程07:路由与多视图
通过命令:git checkout -f step-7 下载了第七课后,在通过命令 npm start 启动项目时,抛出异常:
E:\workspaces\WebStorm workspaces\angular-phonecat>npm start
> angular-phonecat@0.0.0 prestart E:\workspaces\WebStorm workspaces\angular-phon
ecat
> npm install
> angular-phonecat@0.0.0 postinstall E:\workspaces\WebStorm workspaces\angular-p
honecat
> bower install
bower cached git://github.com/angular/bower-angular.git#1.2.17
bower validate 1.2.17 against git://github.com/angular/bower-angular.git#=1
.2.17
bower cached git://github.com/angular/bower-angular-route.git#1.2.17
bower validate 1.2.17 against git://github.com/angular/bower-angular-route.
git#=1.2.17
bower cached git://github.com/angular/bower-angular.git#1.2.20
bower validate 1.2.20 against git://github.com/angular/bower-angular.git#1.
2.20
bower ECONFLICT Unable to find suitable version for angular
npm ERR! angular-phonecat@0.0.0 postinstall: `bower install`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the angular-phonecat@0.0.0 postinstall script.
npm ERR! This is most likely a problem with the angular-phonecat package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! bower install
npm ERR! You can get their info via:
npm ERR! npm owner ls angular-phonecat
npm ERR! There is likely additional logging output above.
npm ERR! System Windows_NT 6.1.7601
npm ERR! command "D:\\Program Files (x86)\\nodejs\\\\node.exe" "D:\\Program File
s (x86)\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install"
npm ERR! cwd E:\workspaces\WebStorm workspaces\angular-phonecat
npm ERR! node -v v0.10.26
npm ERR! npm -v 1.4.3
npm ERR! code ELIFECYCLE
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! E:\workspaces\WebStorm workspaces\angular-phonecat\npm-debug.log
npm ERR! not ok code 0
npm ERR! angular-phonecat@0.0.0 prestart: `npm install`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the angular-phonecat@0.0.0 prestart script.
npm ERR! This is most likely a problem with the angular-phonecat package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! npm install
npm ERR! You can get their info via:
npm ERR! npm owner ls angular-phonecat
npm ERR! There is likely additional logging output above.
npm ERR! System Windows_NT 6.1.7601
npm ERR! command "D:\\Program Files (x86)\\nodejs\\\\node.exe" "D:\\Program File
s (x86)\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "start"
npm ERR! cwd E:\workspaces\WebStorm workspaces\angular-phonecat
npm ERR! node -v v0.10.26
npm ERR! npm -v 1.4.3
npm ERR! code ELIFECYCLE
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! E:\workspaces\WebStorm workspaces\angular-phonecat\npm-debug.log
npm ERR! not ok code 0
提示 bower ECONFLICT Unable to find suitable version for angular
bower 没有找到合适的angular版本。
解决办法:
angular-phonecat 根目录下的 bower.json 文件
{
"name": "angular-seed",
"description": "A starter project for AngularJS",
"version": "0.0.0",
"homepage": "https://github.com/angular/angular-seed",
"license": "MIT",
"private": true,
"dependencies": {
"angular": "1.2.x",
"angular-mocks": "~1.2.x",
"jquery": "1.10.2",
"bootstrap": "~3.1.1",
"angular-route": "~1.2.x"
}
}
把angular 的版本修改,写死为 “=1.2.20”
{
"name": "angular-seed",
"description": "A starter project for AngularJS",
"version": "0.0.0",
"homepage": "https://github.com/angular/angular-seed",
"license": "MIT",
"private": true,
"dependencies": {
"angular": "=1.2.20",
"angular-mocks": "~1.2.x",
"jquery": "1.10.2",
"bootstrap": "~3.1.1",
"angular-route": "=1.2.20"
}
}
然后再用 npm start 命令启动,就能启动成功了。
E:\workspaces\WebStorm workspaces\angular-phonecat>npm start
> angular-phonecat@0.0.0 prestart E:\workspaces\WebStorm workspaces\angular-phon
ecat
> npm install
> angular-phonecat@0.0.0 postinstall E:\workspaces\WebStorm workspaces\angular-p
honecat
> bower install
bower not-cached git://github.com/angular/bower-angular-route.git#=1.2.20
bower resolve git://github.com/angular/bower-angular-route.git#=1.2.20
bower cached git://github.com/angular/bower-angular.git#1.2.20
bower validate 1.2.20 against git://github.com/angular/bower-angular.git#1.
2.20
bower cached git://github.com/angular/bower-angular.git#1.2.20
bower validate 1.2.20 against git://github.com/angular/bower-angular.git#=1
.2.20
bower download https://github.com/angular/bower-angular-route/archive/v1.2.
20.tar.gz
bower extract angular-route#=1.2.20 archive.tar.gz
bower invalid-meta angular-route is missing "ignore" entry in bower.json
bower resolved git://github.com/angular/bower-angular-route.git#1.2.20
bower install angular#1.2.20
bower install angular-route#1.2.20
angular#1.2.20 app\bower_components\angular
angular-route#1.2.20 app\bower_components\angular-route
└── angular#1.2.20
> angular-phonecat@0.0.0 start E:\workspaces\WebStorm workspaces\angular-phoneca
t
> http-server -p 8000
Starting up http-server, serving ./ on port: 8000
Hit CTRL-C to stop the server