Skip to main content

21 posts tagged with "Node.js"

The Node.js runtime.

View All Tags

Introducing Azure DevOps npm auth

· 6 min read
John Reilly
OSS Engineer - TypeScript, Azure, React, Node.js, .NET

Azure DevOps has a feature called Azure Artifacts that supports publishing npm packages to a feed for consumption. Typically those npm packages are intended to be consumed by a restricted audience. To install a package published to a private feed you need to configure authentication, and for non Windows users this is a convoluted process.

title image reading "Introducing Azure DevOps npm auth" with an Azure DevOps and npm logos

Azure DevOps npm auth exists to ease the setting up of local authentication to Azure DevOps npm feeds, particularly for non Windows users.

Azure DevOps API: Set User Story column with the Azure DevOps Client for Node.js

· 5 min read
John Reilly
OSS Engineer - TypeScript, Azure, React, Node.js, .NET

When I attempted to set the column of a User Story in Azure DevOps using the Azure DevOps Client for Node.js, I was surprised to find that the field System.BoardColumn was read-only and I bumped into the error:

TF401326: Invalid field status 'ReadOnly' for field 'System.BoardColumn'.

title image reading "Azure DevOps API: Set User Story column with the Azure DevOps Client for Node.js" with an Azure DevOps logo

This post explains how to set the column of a User Story in Azure DevOps using the Azure DevOps Client for Node.js and it's based in part on a Stack Overflow question.

Static Web Apps CLI: improve performance with Vite server proxy

· 6 min read
John Reilly
OSS Engineer - TypeScript, Azure, React, Node.js, .NET

I often use the Azure Static Web Apps CLI for local development. It's not only handy when building Azure Static Web Apps, but also when building other types of web app, which also rely upon both a frontend server and some kind of API server. The Azure Static Web Apps CLI is particularly handy if you want to spoof authentication / authorization as well.

Changes in the behaviour of Node.js in version 17 caused issues with the Static Web Apps CLI. You can read a previous post which discussed this. However, whilst the issue was fixed in version 1.1.4 of the Static Web Apps CLI, it caused significant performance regressions in the CLIs dev server functionality.

This post shows you how to improve your developer experience by using Vite server proxy instead.

title image reading "Static Web Apps CLI: improve performance with Vite server proxy" with the Static Web Apps CLI and Vite logos

Multiline strings in .env files

· One min read
John Reilly
OSS Engineer - TypeScript, Azure, React, Node.js, .NET

I love using .env files to configure my applications. They're a great way to keep configuration in one place and to keep it out of the codebase. They're also a great way to keep secrets out of the codebase.

But what if you need to use a multiline string in a .env file? How do you do that? You just do it:

SINGLE_LINE="you know what..."
MULTI_LINE="you know what you did
LAST SUMMER"

That's right, you just use a newline character. It's that simple. Oddly, searching for that on the internet didn't yield the answer I was looking for. So I'm writing it down here for posterity.

With your .env file in place, you can then consume it in your application using a package like dotenv. Or if you'd like to use a bash script to consume the .env file, you can do it like this:

#!/usr/bin/env bash
set -a
source test.env
set +a

npm run start # or whatever you need to do

Static Web Apps CLI and Node.js 18: could not connect to API

· 3 min read
John Reilly
OSS Engineer - TypeScript, Azure, React, Node.js, .NET

I make use of Azure Static Web Apps a lot. I recently upgraded to Node.js 18 and found that the Static Web Apps CLI no longer worked when trying to run locally; the API would not connect when running swa start:

[swa] ❌ Could not connect to "https://localhost:7071/". Is the server up and running?

This post shares a workaround. This works for v1.1.3 or earlier of the Static Web Apps CLI. If you're using v1.1.4 or later, you should not need this workaround. But in that case you might find this post helpful on improving performance with 1.1.4 or later.

title image reading "Static Web Apps CLI and Node.js 18: could not connect to API" with the Static Web Apps CLI and Node.js logos

Migrating from ts-node to Bun

· 10 min read
John Reilly
OSS Engineer - TypeScript, Azure, React, Node.js, .NET

I've wanted to take a look at some of the alternative JavaScript runtimes for a while. The thing that has held me back is npm compatibility. I want to be able to run my code in a runtime that isn't Node.js and still be able to use npm packages. I've been using ts-node for a long time now; it's what I reach for when I'm building any kind of console app. In this post I want to port a console app from ts-node to Bun and see how easy it is.

title image reading "From ts-node to Bun"

Node.js 18, Axios and unsafe legacy renegotiation disabled

· 3 min read
John Reilly
OSS Engineer - TypeScript, Azure, React, Node.js, .NET

Node.js 18 doesn't allow legacy TLS renegotion by default. But some APIs still need it. Also, corporate network traffic network is often subject to SSL inspection and that can manifest as a downgrade in TLS negotiation. Palo Alto Networks SSL Inbound Inspection is an example of an SSL inspector that can downgrade TLS.

This post shows how to support work around this issue with Axios.

title image reading "Node.js 18, Axios and unsafe legacy renegotiation disabled" and Axios / Node.js logos

Azure Pipelines - Node.js 16 and custom pipelines task extensions

· 5 min read
John Reilly
OSS Engineer - TypeScript, Azure, React, Node.js, .NET

Support for Node.js 16 for Azure Pipelines custom pipelines task extensions has arrived. From a TypeScript perspective, this post documents how to migrate from a Node.js 10 custom task to one that runs on Node 16 using azure-pipelines-task-lib.

title image reading "Azure Pipelines - Node.js 16 and custom pipelines task extensions" with Azure Pipelines, Node.js and TypeScript logos

Updated 26th September 2024 - Node.js 20 support available

It's now possible to use Node.js 20 in tasks! See more details below:

What's more we're going to start to see warnings emitted in pipelines when an EOL Node version is used.

Adding lastmod to sitemap based on git commits

· 5 min read
John Reilly
OSS Engineer - TypeScript, Azure, React, Node.js, .NET

This post demonstrates enriching an XML sitemap with lastmod timestamps based on git commits. The sitemap being enriched in this post was generated automatically by Docusaurus. The techniques used are predicated on the way Docusaurus works; in that it is file based. You could easily use this technique for another file based website solution; but you would need tweaks to target the relevant files you would use to drive your lastmod.

If you're interested in applying the same technique to your RSS / Atom / JSON feeds in Docusaurus, you may find this post interesting.

title image reading "Adding lastmod to sitemap based on git commits" with XML and Docusaurus logos

Windows Defender Step Away From npm

· 2 min read
John Reilly
OSS Engineer - TypeScript, Azure, React, Node.js, .NET

Updated 18/06/2017

Whilst things did improve by fiddling with Windows Defender it wasn't a 100% fix which makes me wary. Interestingly, VS Code was always open when I did experience the issue and I haven't experienced it when it's been closed. So it may be the cause. I've opened an issue for this against the VS Code repo - it sounds like other people may be affected as I was. Perhaps this is VS Code and not Windows Defender. Watch that space...

Updated 12/07/2017

The issue was VS Code. The bug has now been fixed and shipped last night with VS Code 1.14.0. Yay!

Definitely Typed Shouldn't Exist

· 11 min read
John Reilly
OSS Engineer - TypeScript, Azure, React, Node.js, .NET

I'm a member of the Definitely Typed team - and hopefully I won't be kicked out for writing this. My point is this: .d.ts files should live with the package they provide typing information for, in npm / GitHub etc. Not separately.

Gulp, npm, long paths and Visual Studio.... Fight!

· 3 min read
John Reilly
OSS Engineer - TypeScript, Azure, React, Node.js, .NET

How I managed to gulp-angular-templatecache working inside Visual Studio

Every now and then something bites you unexpectedly. After a certain amount of pain, the answer comes to you and you know you want to save others from falling into the same deathtrap.

There I was minding my own business and having a play with a Gulp plugin called gulp-angular-templatecache. If you're not aware of it, it "Concatenates and registers AngularJS templates in the $templateCache". I was planning to use it so that all the views in an Angular app of mine were loaded up-front rather than on demand. (It's a first step in making an "offline-first" version of that particular app.)