简体   繁体   English

将Angular2更新到最新版本

[英]Update Angular2 to latest version

I am trying to update Angular2 to the latest version release candidate 4. 我正在尝试将Angular2更新为最新版本候选版本4。

I have executed npm outdated and edited accordingly the package.json file. 我已经执行了过时的npm并相应地编辑了package.json文件。 Then I have executed npm update which failed. 然后我执行了npm更新失败了。 I haven't saved the error message. 我没有保存错误消息。 In the following I googled and tried several different npm commands. 在下面我用Google搜索并尝试了几个不同的npm命令。 Unfortunately I cannot recall them. 不幸的是我不记得了。

The current status is, that npm update does not show anything; 目前的状态是, npm update没有显示任何内容; so seems to work. 所以似乎工作。 The command npm start starts the server, but the browser console displays multiple errors. 命令npm start启动服务器,但浏览器控制台显示多个错误。 The first is: 首先是:

http://localhost:3000/node_modules/@angular/platform-browser-dynamic/platform-browser-dynamic.umd.js Failed to load resource: the server responded with a status of 404 (Not Found)

Besides npm install shows the following warnings: 除了npm install之外还会显示以下警告:

typings WARN deprecated 2016-06-02: "registry:dt/core-js#0.0.0+20160317120654" is deprecated (updated, replaced or removed)
typings WARN deprecated 2016-06-22: "registry:dt/node#4.0.0+20160509154515" is deprecated (updated, replaced or removed)
typings WARN deprecated 2016-06-22: "registry:dt/jasmine#2.2.0+20160505161446" is deprecated (updated, replaced or removed)

├── core-js (global)
├── jasmine (global)
└── node (global)

npm WARN optional Skipping failed optional dependency /chokidar/fsevents:
npm WARN notsup Not compatible with your operating system or architecture: fsevents@1.0.12
npm WARN optional Skipping failed optional dependency /lite-server/browser-sync/chokidar/fsevents:
npm WARN notsup Not compatible with your operating system or architecture: fsevents@1.0.12
npm WARN @angular/core@2.0.0-rc.4 requires a peer of rxjs@5.0.0-beta.6 but none was installed.
npm WARN @angular/http@2.0.0-rc.4 requires a peer of rxjs@5.0.0-beta.6 but none was installed.
npm WARN @angular/router@3.0.0-beta.2 requires a peer of rxjs@5.0.0-beta.6 but none was installed.
npm WARN @angular/router-deprecated@2.0.0-rc.1 requires a peer of @angular/core@2.0.0-rc.1 but none was installed.
npm WARN @angular/router-deprecated@2.0.0-rc.1 requires a peer of @angular/common@2.0.0-rc.1 but none was installed.
npm WARN @angular/router-deprecated@2.0.0-rc.1 requires a peer of @angular/platform-browser@2.0.0-rc.1 but none was installed.
npm WARN angular2-in-memory-web-api@0.0.14 requires a peer of rxjs@5.0.0-beta.6 but none was installed.

The package.json relevant parts are currently: package.json相关部分目前是:

"dependencies": {
    "@angular/common": "2.0.0-rc.4",
    "@angular/compiler": "2.0.0-rc.4",
    "@angular/core": "2.0.0-rc.4",
    "@angular/http": "2.0.0-rc.4",
    "@angular/platform-browser": "2.0.0-rc.4",
    "@angular/platform-browser-dynamic": "2.0.0-rc.4",
    "@angular/router": "3.0.0-beta.2",
    "@angular/upgrade": "2.0.0-rc.4",
    "angular2-in-memory-web-api": "0.0.14",
    "angular2-uuid": "^1.0.7",
    "bootstrap": "^3.3.6",
    "core-js": "^2.4.0",
    "reflect-metadata": "^0.1.3",
    "rxjs": "5.0.0-beta.9",
    "systemjs": "0.19.31",
    "zone.js": "^0.6.12"
  },
"devDependencies": {
    "concurrently": "^2.0.0",
    "lite-server": "^2.2.0",
    "typescript": "^1.8.10",
    "typings": "^1.0.4",
    "canonical-path": "0.0.2",
    "http-server": "^0.9.0",
    "tslint": "^3.7.4",
    "lodash": "^4.11.1",
    "jasmine-core": "~2.4.1",
    "karma": "^1.1.0",
    "karma-chrome-launcher": "^1.0.1",
    "karma-cli": "^1.0.1",
    "karma-htmlfile-reporter": "^0.3.4",
    "karma-jasmine": "^1.0.2",
    "protractor": "^3.3.0",
    "rimraf": "^2.5.2"
  },

Follow these steps: 跟着这些步骤:

  1. Delete node_modules folder. 删除node_modules文件夹。

  2. Take latest package.json from https://angular.io/guide/quickstart https://angular.io/guide/quickstart获取最新的package.json

  3. Run 'npm install' command. 运行'npm install'命令。

In typings.json one must update to new registry value, if problem shows up for core-js 在typings.json中,如果出现core-js的问题,则必须更新到新的注册表值

"core-js": "registry:dt/core-js#0.0.0+20160317120654" “core-js”:“注册表:dt / core-js#0.0.0 + 20160317120654”

to

"core-js": "registry:dt/core-js#0.0.0+20160725163759" “core-js”:“注册表:dt / core-js#0.0.0 + 20160725163759”

https://github.com/mgechev/angular2-seed/commit/8a8c64e0e8b18cd0c19c1ab2f1dc71a30bbd6174 https://github.com/mgechev/angular2-seed/commit/8a8c64e0e8b18cd0c19c1ab2f1dc71a30bbd6174

This might be outdated but your typings were never addressed. 这可能已经过时,但您的打字从未得到解决。 Given that you would want to always keep them up to date. 鉴于您希望始终保持最新状态。 Also for anyone else seeking to know about the update process 也适用于任何想要了解更新过程的人

Here is how you could update/reinstall them 以下是更新/重新安装它们的方法

Example: For your node to update it simply type 示例:要为您的节点更新它,只需键入

typings install dt~node --save --global

The following will update your node typings which would be in /typings/global/node 以下将更新您在/typings/global/node

If you did not have node the same command would suffice and your index.d.ts will also be update with a new entry! 如果你没有节点,那么相同的命令就足够了,你的index.d.ts也会用新条目更新!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM