Tuesday, 15 March 2011

Can I use the native 'fs' filesystem in Node.JS on Microsoft Azure? -


I have given Azure the working bit of the Nodes JS code. It uses the Z-view engine, dragging it into the template via the FS file library:

  function generator email (email type, parameter, callback) {fs.readFile (__ parentDir + '/ Email templates'' + Email type + '.zed', 'UTF8', function (mistake, data) {var fn = jade.compile (data); var body = FN ({data: parameters, moment: moment }}; // The template is going to callback (body);});   

}

This works fine on my Mac locally, but the provided email templates & lt; Undefined & gt; & Lt; / Undefined & gt; Received from the Azure Deployment I am afraid that there is something fun on Azure, where I can not use 'FS' to load files and instead may need to use Blobs.

Is this a limit in Azar? Or can not it be related to this problem. Readfile method?

As a prudent investigation, I deployed it to nodjetsu and it works fine.

Many thanks!

It was my problem with blue and node. Js After digging with several node variables, I found that the solution was to use the __file.

As a quick way to test this, you can add something to your app.js:

  // global baseDir = __dirname;   

Then you can access this global variable from anywhere. That means inside the router folder.

  var defaultFile = path.join (baseDir, 'sample.txt');   

Always return the directory name to the current file. If you define a variable with this value from the file in the original value then you have an application base folder. I have implemented this and I am working as Aja ure and Heroko.

No comments:

Post a Comment