Search code examples
javascriptmeteordirectoryprogrammatically-created

Create local folder programmatically in MeteorJS


Is there a way to create local folder in JavaScript using MeteorJS?

PS: App is hosted on Ubuntu server.


Solution

  • Use the meteorhacks:npm library to import the Node.js library fs, then you can do all sorts of file manipulation. Add fs to your packages.json file, then you can do:

    var fs = Meteor.npmRequire('fs');
    fs.mkdirSync(YOUR_PATH_STRING);
    

    There's also an async version, and I've heard mkdirp is also popular as a node package.

    Hope that helps!