HomeBlogTexas Ranger

The good, the bad and the ugly, nodejs 64-bit on azure

The good

Our previous posts covered the development, deployment and monitoring of TypeScript/nodejs apps on azure. I really appreciate the ease of azure-PAAS: Deploy your app and that's it!

The bad

That's it? Not quite. The azure-deployment drives my crazy eventually. I recently developed a React-web-app for scanning barcodes and taking photos for incident reports. Since the smartphones' camera resolutions are excellent, the images get big. I'm using the node sharp-library to shrink/process the images on the server and I love it. But: The sharp-installation via npm requires node-gyp (see the post on azure-deployment) and a 64-bit version of nodejs. Quite naively I thought: "Well it can't be too hard to switch to 64-bit nodejs on azure". Boy was I wrong!

The ugly

First: It's not enough to set WEBSITE_NODE_DEFAULT_VERSION (see my deployment-post). Somehow, you need to tell azure to use a different node-version. As mentioned in the other post, one can define the node-exe-path in the iisnode.yml config-file. But this will only be used to run your app. It has nothing to do with the node-version beeing used for npm install.

In addition, one must set languageWorkers:node:defaultExecutablePath as-app-setting in the azure portal (Application => Settings => Configuration). For a few weeks now, microsoft has been providing "secret" 64-bit node-versions in d:\program files. As of writing this post, its version 10.15.2. So the setting must be: languageWorkers:node:defaultExecutablePath = D:\Program Files\nodejs\10.15.2. And also: WEBSITE_NODE_DEFAULT_VERSION = D:\Program Files\nodejs\10.15.2

This is the secret sauce to tell azure which nodejs version to use for "all activities apart from running the app". (I.e. for npm-install, node-gyp etc.)

Second: It's easy to upload your own node-exe to azure: Go to the advanced tools (kudu-tools), open DEBUG CONSOLE => CMD and drag & drop a zip-file to e.g. d:\home\. kudu will upload and automatically unpack it. Thats nice but this version cannot be used in languageWorkers:node:defaultExecutablePath = D:\Program Files\nodejs\10.15.2. I don't know why. :-)

The good again

The good news: MSFT is working on nodejs-improvements cosntantly. So soon, it will be easier to install and run a 64-bit nodejs-app and a 64-bit npm-install. I want to thank github/@mhoeger who pointed me to the languageWorkers:node:defaultExecutablePath "trick".