hassio-addons/addon-node-red

Unable to apply init_commands to set env var #281

regystro posted onGitHub

Problem/Motivation

I'm tryng to fix the lack of internationalization support as they state here https://github.com/nodejs/node/issues/8500#issuecomment-246432058 = only en-US locale is included in nodejs to minimize file size.

Installing full-icu npm module fixes the problem, but it needs environment variable NODE_ICU_DATA. I'm trying to set it through init_commands, but it doesn't seem to work.

Expected behavior

Environment variable NODE_ICU_DATA should be created.

Actual behavior

I'm entering the container's shell once started, but the environment var is not set.

Steps to reproduce

Add tou your add-on config:

 "npm_packages": [
    "full-icu"
  ],
  "init_commands": [
    "NODE_ICU_DATA=/opt/node_modules/full-icu"
  ]

Then create a simple test function node:

var event = new Date("Thu Aug 01 13:49:33 +0000 2019");
var options = { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric' };
msg.payload = event.toLocaleString('de-DE', options);
return msg;

The output should be "Donnerstag, 1. August 2019", but instead it throws "Thursday, August 1, 2019"

Thank you


The install instructions show how to set a TZ env variable, can you do the same for this? i.e. in settings.js add:

process.env.NODE_ICU_DATA = "/opt/node_modules/full-icu";

posted by sinclairpaul over 5 years ago

Thank you. I managed to set the envvar as @sinclairpaul stated, and even read it from Node-RED nodes (you need to add env: process.envto the ‘functionGlobalContext:’ section of the settings.js file to do so) but full-icu is not working. I'll try to isolate the problem with a docker-less setup and post again if I succeed.

Greetings :)

posted by regystro over 5 years ago

This thread has been automatically locked because it has not had recent activity. Please open a new issue for related bugs and link to relevant comments in this thread.

posted by addons-assistant[bot] over 5 years ago

Fund this Issue

$0.00
Funded

Pull requests