如何更新 ember 个软件包?

How to update ember packages?

我的旧项目使用 Ember 2.8.

现在,我想更新所有的包,这里是更新后的 package.json

{
  "name": "php-api-ember-test",
  "version": "0.0.0",
  "description": "Small description for php-api-ember-test goes here",
  "directories": {
    "doc": "doc",
    "test": "tests"
  },
  "scripts": {
    "build": "ember build",
    "start": "ember server",
    "test": "ember test"
  },
  "repository": "",
  "author": "",
  "license": "MIT",
  "devDependencies": {
    "broccoli-asset-rev": "^2.4.5",
    "ember-ajax": "^3.0.0",
    "ember-cli": "~2.14.2",
    "ember-cli-app-version": "^3.0.0",
    "ember-cli-babel": "^6.3.0",
    "ember-cli-bootstrap-4": "^0.3.2",
    "ember-cli-dependency-checker": "^1.3.0",
    "ember-cli-eslint": "^3.0.0",
    "ember-cli-htmlbars": "^2.0.1",
    "ember-cli-htmlbars-inline-precompile": "^0.4.3",
    "ember-cli-inject-live-reload": "^1.4.1",
    "ember-cli-jshint": "^1.0.0",
    "ember-cli-qunit": "^4.1.0",
    "ember-cli-release": "^0.2.9",
    "ember-cli-sass": "5.5.1",
    "ember-cli-sri": "^2.1.0",
    "ember-cli-test-loader": "^1.1.0",
    "ember-cli-uglify": "^1.2.0",
    "ember-data": "~2.14.9",
    "ember-export-application-global": "^2.0.0",
    "ember-load-initializers": "^1.0.0",
    "ember-resolver": "^4.0.0",
    "ember-welcome-page": "^3.0.0",
    "loader.js": "^4.2.3"
  },
  "engines": {
    "node": "^4.5 || 6.* || >= 7.*"
  },
  "private": true
}

这是bower.json

{
  "name": "php-api-ember-test",
  "dependencies": {
    "ember": "~2.14.0",
    "ember-cli-shims": "0.1.1"
  }
}

我删除了 bower_componentsnode_modules 文件夹,然后 运行 命令npm install && bower install。 安装完成后,我 运行 ember init 得到了这个结果。

Missing npm packages:
Package: ember-ajax
  * Specified: ^3.0.0
  * Installed: 2.5.6

Package: ember-cli-app-version
  * Specified: ^3.0.0
  * Installed: 1.0.1

Package: ember-cli-babel
  * Specified: ^6.3.0
  * Installed: 5.2.4

Package: ember-cli-htmlbars
  * Specified: ^2.0.1
  * Installed: 1.3.4

Package: ember-cli-htmlbars-inline-precompile
  * Specified: ^0.4.3
  * Installed: 0.3.13

Package: ember-cli-qunit
  * Specified: ^4.1.0
  * Installed: 2.2.6

Package: ember-export-application-global
  * Specified: ^2.0.0
  * Installed: 1.1.1

Package: ember-load-initializers
  * Specified: ^1.0.0
  * Installed: 0.5.1

Package: ember-resolver
  * Specified: ^4.0.0
  * Installed: 2.1.1

Package: ember-welcome-page
  * Specified: ^3.0.0
  * Installed: 1.0.4

Run `npm install` to install missing dependencies.

An error occured in the constructor for ember-cli-dependency-checker

但我已经运行 npm install 命令很多次了。

如何更新 Ember 包?

不要使用 npm。使用纱线。它更快、更安全并且具有更好的缓存。它也被推荐作为 Bower(由 Bower)的迁移路径。 Ember 团队也推荐 Yarn 而不是 npm。

rm -rf node_modules
yarn

官方升级文档在这里:ember-cli upgrade. Details are in release notes

首先,有一些不同的步骤:

  1. 设置全局 ember-cli
  2. 正在升级项目ember版本
  3. 正在升级所有其他插件

你最好一步一步来。

顺便看看你通过的所有版本的发行说明。因为可能会有一些差异。例如,对于旧版本(2.14、2.13..),有 bower cache cleanbower install 步骤。对于新版本 (2.15),这些步骤不是必需的。

使用yarn选择包更新

yarn upgrade-interactive --latest