{"id":35,"date":"2018-04-23T23:52:30","date_gmt":"2018-04-23T23:52:30","guid":{"rendered":"http:\/\/www.bullcrane.com\/angular\/?p=35"},"modified":"2018-05-10T17:03:16","modified_gmt":"2018-05-10T17:03:16","slug":"upgrading-angular","status":"publish","type":"post","link":"http:\/\/www.bullcrane.com\/angular\/2018\/04\/23\/upgrading-angular\/","title":{"rendered":"Upgrading Angular"},"content":{"rendered":"<p>When the Google Angular team releases a new version I like to move onto it.\u00a0 I do this by upgrading Angular, starting a new project, and then bringing in the source code from my existing project.<\/p>\n<p>I&#8217;ve been doing my Angular development on an Amazon Web Services Ubuntu Linux server.\u00a0 The examples I show here are Linux operating system commands that overwrite files.\u00a0 Please be careful and do not expect that I will be accountable if you try this and anything goes wrong.\u00a0 Consider making a backup of your system before you begin.<\/p>\n<p><strong>[10-May-2018:\u00a0 I don&#8217;t have this working yet for Angular 6.\u00a0 I think the problem is that flex-layout is not yet published for Angular 6.\u00a0 Waiting for that.]<\/strong><\/p>\n<h6>Record the old version numbers<\/h6>\n<p>As a reference, I issue the <em>ng version<\/em> command in my existing project and keep a copy of the results in an open text editing window.\u00a0 Here my old existing project is <em>randomizer<\/em>:<\/p>\n<pre>cd ~\/randomizer\/\r\nng version<\/pre>\n<p>Then I proceed with my upgrade process.<\/p>\n<h6>Upgrade Angular and create new project<\/h6>\n<p>To upgrade Angular I actually just install it again.\u00a0 Here my new project name is <em>shufflizer:<\/em><\/p>\n<pre>npm install -g @angular\/cli\r\nnpm install --save @angular\/material @angular\/cdk\r\nnpm install @angular\/flex-layout --save\r\n\r\nng new shufflizer<\/pre>\n<p>I do a build of the new project at this point to confirm.\u00a0 It&#8217;s the stock starter project.\u00a0 There should be no error messages:<\/p>\n<pre>cd ~\/shufflizer\/\r\nng build --target=production --base-href '\/trashthis\/'<\/pre>\n<p>Also at this point I can issue the <em>ng version<\/em> command in the new project and confirm that I am running a new version of Angular.\u00a0 I look to see that the version numbers are mostly higher than the <em>ng version<\/em> results from my old project.\u00a0 If they are then I figure I must be on the right track:<\/p>\n<pre>cd ~\/shufflizer\/\r\nng version<\/pre>\n<p>Example results:<\/p>\n<pre>Angular CLI: 1.7.4\r\nNode: 9.0.0\r\nOS: linux x64\r\nAngular: 5.2.10\r\n... animations, common, compiler, compiler-cli, core, forms\r\n... http, language-service, platform-browser\r\n... platform-browser-dynamic, router\r\n\r\n@angular\/cdk: 5.2.5\r\n@angular\/cli: 1.7.4\r\n@angular\/flex-layout: 5.0.0-beta.14\r\n@angular\/material: 5.2.5\r\n@angular-devkit\/build-optimizer: 0.3.2\r\n@angular-devkit\/core: 0.3.2\r\n@angular-devkit\/schematics: 0.3.2\r\n@ngtools\/json-schema: 1.2.0\r\n@ngtools\/webpack: 1.10.2\r\n@schematics\/angular: 0.3.2\r\n@schematics\/package-update: 0.3.2\r\ntypescript: 2.5.3\r\nwebpack: 3.11.0<\/pre>\n<h6>Bring in the source code from my existing project<\/h6>\n<p>Again, my old project is <em>randomizer<\/em>.\u00a0 The new project is <em>shufflizer.<\/em><\/p>\n<p>The <em>cp ~-<\/em> command syntax is the Unix\/Linux way to copy a file from the previous directory into the current directory.\u00a0 The <em>cp -r<\/em> gets subdirectories and their contents too:<\/p>\n<pre>cd ~\/randomizer\/src\/\r\ncd ~\/shufflizer\/src\/\r\ncp ~-\/index.html .\r\ncp ~-\/styles.css .\r\ncd ~\/shufflizer\/src\/app\/\r\ncp -r ~\/randomizer\/src\/app\/* .<\/pre>\n<p>Now I can build the new project. It&#8217;s a new version of the project that I have been working on.\u00a0 It builds totally clean, with the latest version of Angular.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>When the Google Angular team releases a new version I like to move onto it.\u00a0 I do this by upgrading Angular, starting a new project, and then bringing in the source code from my existing project. I&#8217;ve been doing my Angular development on an Amazon Web Services Ubuntu Linux server.\u00a0 The examples I show here &hellip; <\/p>\n<p class=\"link-more\"><a href=\"http:\/\/www.bullcrane.com\/angular\/2018\/04\/23\/upgrading-angular\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Upgrading Angular&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[4],"tags":[],"_links":{"self":[{"href":"http:\/\/www.bullcrane.com\/angular\/wp-json\/wp\/v2\/posts\/35"}],"collection":[{"href":"http:\/\/www.bullcrane.com\/angular\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.bullcrane.com\/angular\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.bullcrane.com\/angular\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.bullcrane.com\/angular\/wp-json\/wp\/v2\/comments?post=35"}],"version-history":[{"count":12,"href":"http:\/\/www.bullcrane.com\/angular\/wp-json\/wp\/v2\/posts\/35\/revisions"}],"predecessor-version":[{"id":117,"href":"http:\/\/www.bullcrane.com\/angular\/wp-json\/wp\/v2\/posts\/35\/revisions\/117"}],"wp:attachment":[{"href":"http:\/\/www.bullcrane.com\/angular\/wp-json\/wp\/v2\/media?parent=35"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.bullcrane.com\/angular\/wp-json\/wp\/v2\/categories?post=35"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.bullcrane.com\/angular\/wp-json\/wp\/v2\/tags?post=35"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}