Node ICU data causes project to fail to load properly

Hi,

I’m trying to use full ICU data from https://www.npmjs.com/package/full-icu, and the environment variable NODE_ICU_DATA=node_modules/full-icu but seems that if I do, when the project goes to sleep and recovers, I need to run rm -rf node_modules && pnpm install before it starts to work again.

Any ideas what might be going wrong here?

Joe

While node_modules isn’t part of the 200MB storage restriction on Glitch, it does have a separate storage limit of 1GB. Probably you’ll need to find another service; Glitch is generally not suited for data-intensive / CPU-intensive applications.

i would suggest sending a JSON string with the packages to a dataserver, and load it from there automatically on startup, i use this often for python and c++( i make my own package managers ) so they do not crash in glitch.

if your wondering how it works it is like this:


var db = new PKG_SERVER();

db.send([{pkg:'lodash', version:'*'}, {pkg:'node-gyp', version:'*'}, {pkg:'FLRM', version:'*.2'}])

db.on('load', (pkgs) => {
 var exe = require('child_process').execSync;
var versions = pkgs.map(t => t.version);
var pd = pkgs.map(t => t.pkg);
for (let i = 0; i<pd.size; i++){
exe(`npm i ${pd[i]}@${versions[i]}`
}
});
module.exports = db.load;

this should output the installation of the following packages
lodash : *
node-gyp : *
FLRM : 1.0.2

if that doesnt work, after the exe variable is called, add the following line of code:

exe('rm -rf node_modules; declare -x env=null')//sets node-env status to false and resets modules

if you want to install it to the server, replace

exe(`npm i ${pd[i]}@${versions[i]}`

with:

exe(`pnpm install ${pd[i]}@${versions[i]}`

note: if you want to save it to a dataserver for your content of automatic package loading, just dm me XD


the execution to reinstall would be in a separate file which can be concluded by the module.exports at the end of the large blob of code at the top, and the code that would trigger the installation will be the following:

var blahblah = require('./data-serve.js');
blahblah();

Ok, thank you.

Let me just run something by you to make sure I’m not falling foul of the XY problem:

I want to use international date time locales to format dates. Without the full ICU data, this doesn’t work properly.

Is there a better way to implement this?

I don’t think my app is particularly data or CPU intensive beyond this.

Thanks!

Hey @joeinnes I’d be interested in taking a look at this if you’re willing to share your project name. I glanced at the full-icu package and it doesn’t seem like it would cause space problems by itself, so I don’t think the node_modules space limit is the culprit here.