<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>nodejs on Much Ado About IT</title><link>https://it.knightnet.org.uk/tags/nodejs/</link><description>
Recent content about nodejs from Much Ado About IT |
Ramblings and rantings from IT Architect &amp; Designer, Julian Knight</description><generator>Hugo | gohugo.io | Theme twenty-sixteen</generator><language>en-gb</language><copyright>This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.</copyright><lastBuildDate>Mon, 24 Apr 2023 21:27:28 +0000</lastBuildDate><atom:link href="https://it.knightnet.org.uk/tags/nodejs/feed.xml" rel="self" type="application/rss+xml"/><item><title>What JavaScript versions are there and how do they map to Node.JS versions?</title><link>https://it.knightnet.org.uk/kb/node-js/javascript-node-versions/</link><guid isPermaLink="true">https://it.knightnet.org.uk/kb/node-js/javascript-node-versions/</guid><pubDate>Fri, 04 Jan 2019 20:03:59 +0000</pubDate><guid>https://it.knightnet.org.uk/kb/node-js/javascript-node-versions/</guid><description><div>There are now far too many versions of JavaScript. Worse, there are several ways to refer to a JavaScript version. Then we have Node.JS which has its own versioning. This post tries to summarise it all.</div><div>&lt;p>This is just a summary for my own reference. See &lt;a href="#references">References&lt;/a> below for more details.&lt;/p>
&lt;p>Please let me know if there are any errors. I will update the table periodically.&lt;/p>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>ECMA-262 Version&lt;/th>
&lt;th>ECMAScript Year Version&lt;/th>
&lt;th>Publish Date&lt;/th>
&lt;th>Node.JS Version&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>5&lt;/td>
&lt;td>N/A&lt;/td>
&lt;td>2009-12&lt;/td>
&lt;td>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>6&lt;/td>
&lt;td>ES2015&lt;/td>
&lt;td>2015-06&lt;/td>
&lt;td>6.5.0+&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>7&lt;/td>
&lt;td>ES2016&lt;/td>
&lt;td>2016-06&lt;/td>
&lt;td>7.0.0+&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>8&lt;/td>
&lt;td>ES2017&lt;/td>
&lt;td>2017-06&lt;/td>
&lt;td>8.10.0+&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>9&lt;/td>
&lt;td>ES2018&lt;/td>
&lt;td>2018-06&lt;/td>
&lt;td>10.0.0+&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;p>Notes:&lt;/p>
&lt;ul>
&lt;li>Versions of Node.JS prior to those shown are likely to support &lt;em>some&lt;/em> features of newer JS versions. The versions shown are those that support virtually all of the features.&lt;/li>
&lt;li>Some JavaScript features may not be implemented in Node.JS.&lt;/li>
&lt;li>Node uses the V8 JavaScript engine. Also used by the chromium browser (which underpins Vivaldi, Google Chrome, Opera and many others. Soon to be used by Microsoft Edge as well).&lt;/li>
&lt;/ul>
&lt;h2 id="references">References&lt;/h2>
&lt;ul>
&lt;li>&lt;a href="https://en.wikipedia.org/wiki/ECMAScript">Wikipedia ECMAScript Article&lt;/a>&lt;/li>
&lt;li>&lt;a href="https://kangax.github.io/compat-table/es6/">Kangax&amp;rsquo;s JavaScript Compatability Table&lt;/a>&lt;/li>
&lt;li>&lt;a href="https://node.green/">Node Green&lt;/a> - Maps Node versions to JavaScript versions and shows what is supported in each version. Uses Kangax&amp;rsquo;s table.&lt;/li>
&lt;li>&lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript">Mozilla Developer Network (MDN)&lt;/a> - Details each aspect of JavaScript as a reference, each page has a compatibility table showing browsers support. Uses Kangax&amp;rsquo;s table.&lt;/li>
&lt;/ul></div></description><author>Julian Knight</author><category domain="https://it.knightnet.org.uk/categories/development">Development</category><category domain="https://it.knightnet.org.uk/tags/javascript">JavaScript</category><category domain="https://it.knightnet.org.uk/tags/ecmascript">ECMAscript</category><category domain="https://it.knightnet.org.uk/tags/node.js">node.js</category><category domain="https://it.knightnet.org.uk/tags/nodejs">nodejs</category></item><item><title>Download a GitHub Repository using Node.JS</title><link>https://it.knightnet.org.uk/kb/node-js/download-repo-github/</link><guid isPermaLink="true">https://it.knightnet.org.uk/kb/node-js/download-repo-github/</guid><pubDate>Sun, 30 Dec 2018 22:03:07 +0000</pubDate><guid>https://it.knightnet.org.uk/kb/node-js/download-repo-github/</guid><description><div>Downloading a repository from GitHub using Node.JS should be really easy. But it isn't! This KB post reminds us of the tricks required.</div><div>&lt;p>We have to be careful with the source URL names when working with GitHub as the URL&amp;rsquo;s generally exposed on the web interface
are &lt;strong>not&lt;/strong> the actual URL&amp;rsquo;s. The Node.JS http/https get() functions don&amp;rsquo;t handle redirections well.&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-javascript" data-lang="javascript">&lt;span class="line">&lt;span class="cl">&lt;span class="ch">#!/usr/bin/env node
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="ch">&lt;/span>&lt;span class="s1">&amp;#39;use strict&amp;#39;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="cm">/**
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="cm"> * Install the Node-RED alternate installation template
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="cm"> *
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="cm"> * Author: Julian Knight (Totally Information), Jan. 2019
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="cm"> * License: MIT
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="cm"> */&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="kr">const&lt;/span> &lt;span class="nx">fs&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="nx">require&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="s1">&amp;#39;fs&amp;#39;&lt;/span>&lt;span class="p">)&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="kr">const&lt;/span> &lt;span class="nx">https&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="nx">require&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="s1">&amp;#39;https&amp;#39;&lt;/span>&lt;span class="p">)&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="kd">function&lt;/span> &lt;span class="nx">download&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="nx">url&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="nx">dest&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="nx">cb&lt;/span>&lt;span class="p">)&lt;/span> &lt;span class="p">{&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="kr">const&lt;/span> &lt;span class="nx">file&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="nx">fs&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="nx">createWriteStream&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="nx">dest&lt;/span>&lt;span class="p">);&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="kr">const&lt;/span> &lt;span class="nx">request&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="nx">https&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="nx">get&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="nx">url&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="kd">function&lt;/span> &lt;span class="p">(&lt;/span>&lt;span class="nx">response&lt;/span>&lt;span class="p">)&lt;/span> &lt;span class="p">{&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nx">response&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="nx">pipe&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="nx">file&lt;/span>&lt;span class="p">);&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nx">file&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="nx">on&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="s1">&amp;#39;finish&amp;#39;&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="kd">function&lt;/span> &lt;span class="p">()&lt;/span> &lt;span class="p">{&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nx">file&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="nx">close&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="nx">cb&lt;/span>&lt;span class="p">);&lt;/span> &lt;span class="c1">// close() is async, call cb after close completes.
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1">&lt;/span> &lt;span class="p">});&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">}).&lt;/span>&lt;span class="nx">on&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="s1">&amp;#39;error&amp;#39;&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="kd">function&lt;/span> &lt;span class="p">(&lt;/span>&lt;span class="nx">err&lt;/span>&lt;span class="p">)&lt;/span> &lt;span class="p">{&lt;/span> &lt;span class="c1">// Handle errors
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1">&lt;/span> &lt;span class="nx">fs&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="nx">unlink&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="nx">dest&lt;/span>&lt;span class="p">);&lt;/span> &lt;span class="c1">// Delete the file async. (But we don&amp;#39;t check the result)
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1">&lt;/span> &lt;span class="k">if&lt;/span> &lt;span class="p">(&lt;/span>&lt;span class="nx">cb&lt;/span>&lt;span class="p">)&lt;/span> &lt;span class="nx">cb&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="nx">err&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="nx">message&lt;/span>&lt;span class="p">);&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">});&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="p">};&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1">// Download latest archive from GitHub to temp folder
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1">&lt;/span>&lt;span class="kr">const&lt;/span> &lt;span class="nx">dest&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="s1">&amp;#39;./alternate-node-red-installer.zip&amp;#39;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="kr">const&lt;/span> &lt;span class="nx">url&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="s1">&amp;#39;https://codeload.github.com/TotallyInformation/alternate-node-red-installer/zip/master&amp;#39;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="nx">download&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="nx">url&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="nx">dest&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="kd">function&lt;/span>&lt;span class="p">(){&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nx">console&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="nx">log&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="s1">&amp;#39;Done&amp;#39;&lt;/span>&lt;span class="p">)&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="p">})&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Obviously, it would be better to add proper error traps and messaging.&lt;/p>
&lt;h2 id="github-urls">GitHub URL&amp;rsquo;s&lt;/h2>
&lt;p>As mentioned, most of the exposed GitHub URL&amp;rsquo;s actually redirect which upsets Node&amp;rsquo;s built-in
get functions. The downside of using the direct URL&amp;rsquo;s is that they may change format from
time-to-time. If you can, use a 3rd-party library such as &lt;a href="https://github.com/request/request">request&lt;/a>
which handles http vs https and redirects without additional programming.&lt;/p>
&lt;p>The format for the actual repository archives (in zipped form) is:&lt;/p>
&lt;p>&lt;code>https://codeload.github.com/&amp;lt;userOrOrgName&amp;gt;/&amp;lt;repoName&amp;gt;/zip/&amp;lt;branch&amp;gt;&lt;/code>&lt;/p>
&lt;p>Where: &lt;code>&amp;lt;branch&amp;gt;&lt;/code> is either &amp;lsquo;master&amp;rsquo; or a git tag ID (e.g. &amp;lsquo;v1.2.3&amp;rsquo;) or other git branch ID.&lt;/p>
&lt;p>For an individual file from the repository, use:&lt;/p>
&lt;p>&lt;code>raw.githubusercontent.com/&amp;lt;userOrOrgName&amp;gt;/&amp;lt;repository&amp;gt;/&amp;lt;branch&amp;gt;/&amp;lt;filename&amp;gt;&lt;/code>&lt;/p>
&lt;p>&lt;a href="https://raw.githubusercontent.com/TotallyInformation/alternate-node-red-installer/">https://raw.githubusercontent.com/TotallyInformation/alternate-node-red-installer/&lt;/a>&lt;/p>
&lt;h2 id="references">References&lt;/h2>
&lt;ul>
&lt;li>&lt;a href="https://stackoverflow.com/questions/41736280/node-js-does-not-correctly-download-file-from-github-url">Node JS does not correctly download file from github url&lt;/a>&lt;/li>
&lt;li>&lt;a href="https://stackoverflow.com/questions/11944932/how-to-download-a-file-with-node-js-without-using-third-party-libraries">How to download a file with Node.js (without using third-party libraries)?&lt;/a>&lt;/li>
&lt;/ul></div></description><author>Julian Knight</author><category domain="https://it.knightnet.org.uk/categories/development">Development</category><category domain="https://it.knightnet.org.uk/tags/node.js">node.js</category><category domain="https://it.knightnet.org.uk/tags/nodejs">nodejs</category><category domain="https://it.knightnet.org.uk/tags/javascript">JavaScript</category><category domain="https://it.knightnet.org.uk/tags/ecmascript">ECMAscript</category></item><item><title>Using npm configuration environment variables in package.json</title><link>https://it.knightnet.org.uk/kb/node-js/npm-configuration-variables/</link><guid isPermaLink="true">https://it.knightnet.org.uk/kb/node-js/npm-configuration-variables/</guid><pubDate>Sun, 30 Dec 2018 22:03:07 +0000</pubDate><guid>https://it.knightnet.org.uk/kb/node-js/npm-configuration-variables/</guid><description><div>npm automatically makes parts of your package.json file available as environment variables. This can be useful when using npm as a run script service.</div><div>&lt;p>npm exposes all of the entries in &lt;code>package.json&lt;/code> as environment variables so that any script specified in the &lt;code>scripts&lt;/code>
section can make use of them.&lt;/p>
&lt;p>In the example below we can see both the advantage and the weakness of the approach.&lt;/p>
&lt;p>The advantage is that we can pass things like the module version number direct to another command.&lt;/p>
&lt;p>The weakness is that the consumption of environment variables is different depending on the operating
system in use.&lt;/p>
&lt;p>Every property in &lt;code>package.json&lt;/code> is exposed this way, simply prefix with &lt;code>npm_package_&lt;/code>
and replace subscripts (e.g. &lt;code>scripts.patch&lt;/code>) with an underscore (e.g. &lt;code>npm_package_scripts_patch&lt;/code>).&lt;/p>
&lt;h2 id="example-packagejson">Example package.json&lt;/h2>
&lt;p>We can use this for reference&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-json" data-lang="json">&lt;span class="line">&lt;span class="cl">&lt;span class="p">{&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nt">&amp;#34;name&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="s2">&amp;#34;Config Example&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nt">&amp;#34;version&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="s2">&amp;#34;1.2.3&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nt">&amp;#34;description&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="s2">&amp;#34;Using config variables in package.json&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nt">&amp;#34;author&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="s2">&amp;#34;Max Headroom&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nt">&amp;#34;scripts&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="p">{&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nt">&amp;#34;patch&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="s2">&amp;#34;npm version patch -m \&amp;#34;Patch version bump to %s\&amp;#34; &amp;#34;&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nt">&amp;#34;minor&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="s2">&amp;#34;npm version minor -m \&amp;#34;Minor version bump to %s\&amp;#34; &amp;#34;&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nt">&amp;#34;major&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="s2">&amp;#34;npm version major -m \&amp;#34;Major version bump to %s\&amp;#34;&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nt">&amp;#34;postinstall&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="s2">&amp;#34;node ./postinstall.js&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nt">&amp;#34;win-tag&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="s2">&amp;#34;git tag -a v%npm_package_version% -m \&amp;#34;Release v%npm_package_version%\&amp;#34;; git push origin --tags&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nt">&amp;#34;tag&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="s2">&amp;#34;git tag -a v$npm_package_version -m \&amp;#34;Release v$npm_package_version\&amp;#34; &amp;amp;&amp;amp; git push origin --tags&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">},&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nt">&amp;#34;devDependencies&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="p">{&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nt">&amp;#34;eslint&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="s2">&amp;#34;^1.10.3&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">}&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="p">}&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h2 id="references">References&lt;/h2>
&lt;ul>
&lt;li>&lt;a href="https://frontend.irish/npm-config-variables">Using config variables in package.json&lt;/a>&lt;/li>
&lt;/ul></div></description><author>Julian Knight</author><category domain="https://it.knightnet.org.uk/categories/development">Development</category><category domain="https://it.knightnet.org.uk/tags/node.js">node.js</category><category domain="https://it.knightnet.org.uk/tags/nodejs">nodejs</category><category domain="https://it.knightnet.org.uk/tags/npm">npm</category><category domain="https://it.knightnet.org.uk/tags/json">json</category></item><item><title>Node.JS and JavaScript</title><link>https://it.knightnet.org.uk/kb/node-js/</link><guid isPermaLink="true">https://it.knightnet.org.uk/kb/node-js/</guid><pubDate>Sun, 30 Dec 2018 21:58:14 +0000</pubDate><guid>https://it.knightnet.org.uk/kb/node-js/</guid><description><div>Node.JS allows JavaScript to be used as a server-side (back-end) programming language.</div><div>&lt;h2 id="references">References&lt;/h2>
&lt;ul>
&lt;li>&lt;a href="https://nodejs.org/en/">NodeJS docs and download&lt;/a>&lt;/li>
&lt;li>&lt;a href="https://node.green/">What JavaScript/ECMAscript features does each version of Node.JS support?&lt;/a>&lt;/li>
&lt;li>&lt;a href="https://www.npmjs.com/">npm docs and module search&lt;/a>&lt;/li>
&lt;li>&lt;a href="https://npms.io/">npms - another module search site&lt;/a>&lt;/li>
&lt;li>&lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript">MDN JavaScript reference (searchable)&lt;/a>&lt;/li>
&lt;/ul>
&lt;h2 id="knowledgebase-articles">Knowledgebase Articles&lt;/h2></div></description><author>Julian Knight</author><category domain="https://it.knightnet.org.uk/categories/development">Development</category><category domain="https://it.knightnet.org.uk/tags/node.js">node.js</category><category domain="https://it.knightnet.org.uk/tags/nodejs">nodejs</category><category domain="https://it.knightnet.org.uk/tags/javascript">JavaScript</category><category domain="https://it.knightnet.org.uk/tags/ecmascript">ECMAscript</category></item><item><title>Creating GitHub Releases from git Tags</title><link>https://it.knightnet.org.uk/blog/creating-github-releases-from-git-tags/</link><guid isPermaLink="true">https://it.knightnet.org.uk/blog/creating-github-releases-from-git-tags/</guid><pubDate>Sun, 30 Dec 2018 21:23:20 +0000</pubDate><guid>https://it.knightnet.org.uk/blog/creating-github-releases-from-git-tags/</guid><description><div>The workflow for updating version numbers and doing git/GitHub/npm releases is far too complex to easily remember when you aren't doing it very often. This post is a reminder of the various steps.</div><div>&lt;p>Just a quick reminder for myself mainly.&lt;/p>
&lt;p>GitHub will automatically create a release from a git tag. Having had a request for this from an issue with node-red-contrib-uibuilder, I
decided that I&amp;rsquo;d better look into how to do it.&lt;/p>
&lt;p>Why is everything harder than it should be!? Anyway, here is the raw workflow for committing changes to a git managed repository of code,
creating a tag, pushing both master and the tag to GitHub and then publishing to npm.&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-bash" data-lang="bash">&lt;span class="line">&lt;span class="cl">&lt;span class="c1"># This could be minor or major instead of patch, it updates package.js&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">npm npm version patch -m &lt;span class="s2">&amp;#34;Patch version bump to %s&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1"># We might want to stage instead of committing everything at once&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">git commit -m &lt;span class="s2">&amp;#34;Commit message&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">git push
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1"># Create a tag to match the npm version&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">git tag -a v1.4.1 -m &lt;span class="s2">&amp;#34;my version 1.4.1&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">git push origin --tags
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1"># Publish to npm&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">npm publish
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Of course, the commit and push are easier done direct from VScode.&lt;/p>
&lt;p>It is annoying that I can&amp;rsquo;t link the tag to the npm version.&lt;/p>
&lt;h2 id="references">References&lt;/h2>
&lt;ul>
&lt;li>&lt;a href="https://git-scm.com/book/en/v2/Git-Basics-Tagging">git docs 2.6 Git Basics - Tagging&lt;/a>&lt;/li>
&lt;/ul></div></description><author>Julian Knight</author><category domain="https://it.knightnet.org.uk/categories/development">Development</category><category domain="https://it.knightnet.org.uk/tags/git">git</category><category domain="https://it.knightnet.org.uk/tags/github">github</category><category domain="https://it.knightnet.org.uk/tags/npm">npm</category><category domain="https://it.knightnet.org.uk/tags/node.js">node.js</category><category domain="https://it.knightnet.org.uk/tags/nodejs">nodejs</category></item></channel></rss>