2017-01-09 148 views
0

我想将angular2从版本2.1.1更新到2.4.1 我已经使用this种子项目开始。将angular2从2.1.1升级到版本2.4.1

我的package.json就像

{ 
    "name": "angular2-webpack-starter", 
    "version": "5.1.1", 
    "description": "An Angular 2 Webpack Starter kit featuring Angular 2 (Router, Http, Forms, Services, Tests, E2E, Coverage), Karma, Protractor, Jasmine, Istanbul, TypeScript, and Webpack by AngularClass", 
    "keywords": [ 
    "angular2", 
    "webpack", 
    "typescript" 
    ], 
    "author": "Patrick Stapleton <[email protected]>", 
    "homepage": "https://github.com/angularclass/angular2-webpack-starter", 
    "license": "MIT", 
    "scripts": { 
    "build:dev": "webpack --config config/webpack.dev.js --progress --profile", 
    "build:docker": "npm run build:prod && docker build -t angular2-webpack-start:latest .", 
    "build:prod": "webpack --config config/webpack.prod.js --progress --profile --bail", 
    "build": "npm run build:dev", 
    "ci": "npm run lint && npm test && npm run e2e", 
    "clean:dist": "npm run rimraf -- dist", 
    "clean:install": "npm set progress=false && npm install", 
    "clean:start": "npm start", 
    "clean": "npm cache clean && npm run rimraf -- node_modules doc coverage dist", 
    "docker": "docker", 
    "docs": "npm run typedoc -- --options typedoc.json --exclude '**/*.spec.ts' ./src/", 
    "e2e:live": "npm run e2e -- --elementExplorer", 
    "e2e": "npm run protractor", 
    "github-deploy:dev": "webpack --config config/webpack.github-deploy.js --progress --profile --github-dev", 
    "github-deploy:prod": "webpack --config config/webpack.github-deploy.js --progress --profile --github-prod", 
    "github-deploy": "npm run github-deploy:dev", 
    "lint": "npm run tslint \"src/**/*.ts\"", 
    "postversion": "git push && git push --tags", 
    "prebuild:dev": "npm run clean:dist", 
    "prebuild:prod": "npm run clean:dist", 
    "preclean:install": "npm run clean", 
    "preclean:start": "npm run clean", 
    "pree2e": "npm run webdriver:update -- --standalone", 
    "preversion": "npm test", 
    "protractor": "protractor", 
    "rimraf": "rimraf", 
    "server:dev:hmr": "npm run server:dev -- --inline --hot", 
    "server:dev": "webpack-dev-server --config config/webpack.dev.js --progress --profile --watch --content-base src/", 
    "server:prod": "http-server dist --cors", 
    "server": "npm run server:dev", 
    "start:hmr": "npm run server:dev:hmr", 
    "start": "npm run server:dev", 
    "test": "karma start", 
    "tslint": "tslint", 
    "typedoc": "typedoc", 
    "version": "npm run build", 
    "watch:dev:hmr": "npm run watch:dev -- --hot", 
    "watch:dev": "npm run build:dev -- --watch", 
    "watch:prod": "npm run build:prod -- --watch", 
    "watch:test": "npm run test -- --auto-watch --no-single-run", 
    "watch": "npm run watch:dev", 
    "webdriver-manager": "webdriver-manager", 
    "webdriver:start": "npm run webdriver-manager start", 
    "webdriver:update": "npm run webdriver-manager update", 
    "webpack-dev-server": "webpack-dev-server", 
    "webpack": "webpack" 
    }, 
    "dependencies": { 
    "@angular/common": "2.1.1", 
    "@angular/compiler": "2.1.1", 
    "@angular/core": "2.1.1", 
    "@angular/forms": "^2.1.1", 
    "@angular/http": "2.1.1", 
    "@angular/platform-browser": "2.1.1", 
    "@angular/platform-browser-dynamic": "2.1.1", 
    "@angular/platform-server": "2.1.1", 
    "@angular/router": "3.1.1", 
    "@angularclass/conventions-loader": "^1.0.2", 
    "@angularclass/hmr": "~1.2.0", 
    "@angularclass/hmr-loader": "~3.0.2", 
    "angular2-highcharts": "^0.4.0", 
    "assets-webpack-plugin": "^3.4.0", 
    "core-js": "^2.4.1", 
    "http-server": "^0.9.0", 
    "ie-shim": "^0.1.0", 
    "rxjs": "^5.0.0-rc.1", 
    "zone.js": "~0.6.17" 
    }, 
    "devDependencies": { 
    "@types/hammerjs": "^2.0.33", 
    "@types/jasmine": "^2.2.34", 
    "@types/node": "^6.0.38", 
    "@types/protractor": "^1.5.20", 
    "@types/selenium-webdriver": "2.44.29", 
    "@types/source-map": "^0.1.27", 
    "@types/uglify-js": "^2.0.27", 
    "@types/webpack": "^1.12.34", 
    "angular2-template-loader": "^0.5.0", 
    "awesome-typescript-loader": "^2.2.1", 
    "codelyzer": "~1.0.0-beta.2", 
    "copy-webpack-plugin": "^4.0.0", 
    "css-loader": "^0.25.0", 
    "exports-loader": "^0.6.3", 
    "expose-loader": "^0.7.1", 
    "file-loader": "^0.9.0", 
    "gh-pages": "^0.11.0", 
    "html-webpack-plugin": "^2.21.0", 
    "imports-loader": "^0.6.5", 
    "istanbul-instrumenter-loader": "^1.0.0", 
    "json-loader": "^0.5.4", 
    "karma": "^1.2.0", 
    "karma-chrome-launcher": "^2.0.0", 
    "karma-coverage": "^1.1.1", 
    "karma-jasmine": "^1.0.2", 
    "karma-mocha-reporter": "^2.0.0", 
    "karma-remap-coverage": "^0.1.1", 
    "karma-sourcemap-loader": "^0.3.7", 
    "karma-webpack": "1.8.0", 
    "node-sass": "^4.1.1", 
    "parse5": "^2.2.2", 
    "protractor": "^4.0.9", 
    "raw-loader": "^0.5.1", 
    "rimraf": "^2.5.2", 
    "sass-loader": "^4.1.1", 
    "script-ext-html-webpack-plugin": "^1.3.2", 
    "source-map-loader": "^0.1.5", 
    "string-replace-loader": "1.0.5", 
    "style-loader": "^0.13.1", 
    "to-string-loader": "^1.1.4", 
    "ts-helpers": "1.1.2", 
    "ts-node": "^1.3.0", 
    "tslint": "^4.0.0-dev.0", 
    "tslint-loader": "^2.1.3", 
    "typedoc": "^0.5.0", 
    "typescript": "^2.0.6", 
    "url-loader": "^0.5.7", 
    "webpack": "2.1.0-beta.25", 
    "webpack-dev-middleware": "1.6.1", 
    "webpack-dev-server": "2.1.0-beta.9", 
    "webpack-md5-hash": "0.0.5", 
    "webpack-merge": "0.15.0" 
    }, 
    "repository": { 
    "type": "git", 
    "url": "https://github.com/angularclass/angular2-webpack-starter.git" 
    }, 
    "bugs": { 
    "url": "https://github.com/angularclass/angular2-webpack-starter/issues" 
    }, 
    "engines": { 
    "node": ">= 4.2.1", 
    "npm": ">= 3" 
    } 
} 

然后我的package.json文件更新到下面的代码

{ "name": "angular2-webpack-starter", "version": "5.4.1", "description": "An Angular 2 Webpack Starter kit featuring Angular 2 (Router, Http, Forms, Services, Tests, E2E, Coverage), Karma, Protractor, Jasmine, Istanbul, TypeScript, and Webpack by AngularClass", "keywords": [ 
    "angular2", 
    "webpack", 
    "typescript" ], "author": "Patrick Stapleton <[email protected]>", "homepage": "https://github.com/angularclass/angular2-webpack-starter", "license": "MIT", "scripts": { 
    "build:dev": "webpack --config config/webpack.dev.js --progress --profile", 
    "build:docker": "npm run build:prod && docker build -t angular2-webpack-start:latest .", 
    "build:prod": "webpack --config config/webpack.prod.js --progress --profile --bail", 
    "build": "npm run build:dev", 
    "ci": "npm run lint && npm test && npm run e2e", 
    "clean:dist": "npm run rimraf -- dist", 
    "clean:install": "npm set progress=false && npm install", 
    "clean:start": "npm start", 
    "clean": "npm cache clean && npm run rimraf -- node_modules doc coverage dist", 
    "docker": "docker", 
    "docs": "npm run typedoc -- --options typedoc.json --exclude '**/*.spec.ts' ./src/", 
    "e2e:live": "npm run e2e -- --elementExplorer", 
    "e2e": "npm run protractor", 
    "github-deploy:dev": "webpack --config config/webpack.github-deploy.js --progress --profile --github-dev", 
    "github-deploy:prod": "webpack --config config/webpack.github-deploy.js --progress --profile --github-prod", 
    "github-deploy": "npm run github-deploy:dev", 
    "lint": "npm run tslint \"src/**/*.ts\"", 
    "postversion": "git push && git push --tags", 
    "prebuild:dev": "npm run clean:dist", 
    "prebuild:prod": "npm run clean:dist", 
    "preclean:install": "npm run clean", 
    "preclean:start": "npm run clean", 
    "pree2e": "npm run webdriver:update -- --standalone", 
    "preversion": "npm test", 
    "protractor": "protractor", 
    "rimraf": "rimraf", 
    "server:dev:hmr": "npm run server:dev -- --inline --hot", 
    "server:dev": "webpack-dev-server --config config/webpack.dev.js --progress --profile --watch --content-base src/", 
    "server:prod": "http-server dist --cors", 
    "server": "npm run server:dev", 
    "start:hmr": "npm run server:dev:hmr", 
    "start": "npm run server:dev", 
    "test": "karma start", 
    "tslint": "tslint", 
    "typedoc": "typedoc", 
    "version": "npm run build", 
    "watch:dev:hmr": "npm run watch:dev -- --hot", 
    "watch:dev": "npm run build:dev -- --watch", 
    "watch:prod": "npm run build:prod -- --watch", 
    "watch:test": "npm run test -- --auto-watch --no-single-run", 
    "watch": "npm run watch:dev", 
    "webdriver-manager": "webdriver-manager", 
    "webdriver:start": "npm run webdriver-manager start", 
    "webdriver:update": "npm run webdriver-manager update", 
    "webpack-dev-server": "webpack-dev-server", 
    "webpack": "webpack", "i18n": "ng-xi18n" }, "dependencies": { 
    "@angular/common": "2.4.1", 
    "@angular/compiler": "2.4.1", 
    "@angular/core": "2.4.1", 
    "@angular/forms": "2.4.1", 
    "@angular/http": "2.4.1", 
    "@angular/platform-browser": "2.4.1", 
    "@angular/platform-browser-dynamic": "2.4.1", 
    "@angular/platform-server": "2.4.1", 
    "@angular/router": "3.4.1", 
    "@angularclass/conventions-loader": "1.0.2", 
    "@angularclass/hmr": "~1.2.2", 
    "@angularclass/hmr-loader": "~3.0.2", 
    "angular2-highcharts": "^0.4.0", 
    "assets-webpack-plugin": "^3.4.0", 
    "core-js": "^2.4.1", 
    "http-server": "^0.9.0", 
    "ie-shim": "^0.1.0", 
    "rxjs": "~5.0.2", 
    "zone.js": "~0.7.4" }, "devDependencies": { 
    "@angular/compiler-cli": "2.4.1", 
    "@types/hammerjs": "^2.0.33", 
    "@types/jasmine": "^2.2.34", 
    "@types/node": "^6.0.38", 
    "@types/protractor": "^1.5.20", 
    "@types/selenium-webdriver": "2.53.38", 
    "@types/source-map": "^0.5.0", 
    "@types/uglify-js": "^2.0.27", 
    "@types/webpack": "^1.12.34", 
    "angular2-template-loader": "^0.6.0", 
    "awesome-typescript-loader": "~3.0.0-beta.17", 
    "codelyzer": "~2.0.0-beta.4", 
    "copy-webpack-plugin": "^4.0.0", 
    "css-loader": "^0.26.0", 
    "exports-loader": "^0.6.3", 
    "expose-loader": "^0.7.1", 
    "file-loader": "^0.9.0", 
    "gh-pages": "^0.12.0", 
    "html-webpack-plugin": "^2.21.0", 
    "imports-loader": "^0.7.0", 
    "istanbul-instrumenter-loader": "1.2.0", 
    "json-loader": "^0.5.4", 
    "karma": "^1.2.0", 
    "karma-chrome-launcher": "^2.0.0", 
    "karma-coverage": "^1.1.1", 
    "karma-jasmine": "^1.0.2", 
    "karma-mocha-reporter": "^2.0.0", 
    "karma-remap-coverage": "^0.1.4", 
    "karma-sourcemap-loader": "^0.3.7", 
    "karma-webpack": "1.8.0", 
    "node-sass": "^4.1.1", 
    "parse5": "^2.2.1", 
    "protractor": "^4.0.10", 
    "raw-loader": "0.5.1", 
    "rimraf": "~2.5.4", 
    "sass-loader": "^4.1.1", 
    "script-ext-html-webpack-plugin": "1.3.2", 
    "source-map-loader": "^0.1.5", "string-replace-loader": "1.0.5", 
    "style-loader": "^0.13.1", 
    "to-string-loader": "^1.1.4", 
    "ts-helpers": "1.1.2", 
    "ts-node": "^2.0.0", 
    "tslint": "^4.0.0-dev.0", 
    "tslint-loader": "^3.3.0", 
    "typedoc": "^0.5.3", 
    "typescript": "2.0.10", 
    "url-loader": "^0.5.7", 
    "webpack": "2.1.0-beta.25", 
    "webpack-dev-middleware": "1.6.1", 
    "webpack-dev-server": "2.1.0-beta.9", 
    "webpack-md5-hash": "0.0.5", 
    "webpack-merge": "0.15.0" },  "repository": { 
    "type": "git", 
    "url": "https://github.com/angularclass/angular2-webpack-starter.git" }, "bugs": { 
    "url": "https://github.com/angularclass/angular2-webpack-starter/issues" }, "engines": { 
    "node": ">= 4.2.1", 
    "npm": ">= 3" } } 

我能够运行,但得到以下错误,当我改变的package.json和删除node_modules文件夹并运行命令npm install --save

[at-loader] node_modules\@types\protractor\index.d.ts:11:34 
    Cannot find name 'webdriver'. 

[at-loader] src\app\app.e2e.ts:9:27 
    Property 'getTitle' does not exist on type 'IBrowser'. 

[at-loader] src\app\app.e2e.ts:27:45 
    Property 'getText' does not exist on type 'ElementFinder'. 

[at-loader] src\app\home\home.component.spec.ts:38:17 
    Property 'localState' does not exist on type 'HomeComponent'. 

[at-loader] src\app\home\home.component.spec.ts:42:19 
    Property 'title' does not exist on type 'HomeComponent'. 

[at-loader] src\app\home\home.e2e.ts:10:27 
    Property 'getTitle' does not exist on type 'IBrowser'. 

[at-loader] src\app\home\home.e2e.ts:16:48 
    Property 'getText' does not exist on type 'ElementFinder'. 

回答

0

我能够解决这些错误通过进行以下更改。

1)从'量角器'添加了导入{browser,by,element}; 在app.e2e.ts和home.e2e.ts

2)低于2条语句从home.component.spec.ts

删除它( '应具有默认数据',()=> expect(comp.localState).toEqual({value:''});}); ('应该有一个标题',()=> {expect}(!! comp.title).toEqual(true);});}};