0

I have a server running, I want to get the local system file path where aws server is running using node js

Jamuna
  • 21
  • 5
  • Does this answer your question? [Node.js - Find home directory in platform agnostic way](https://stackoverflow.com/questions/9080085/node-js-find-home-directory-in-platform-agnostic-way) – Nicolas Jan 07 '20 at 13:18
  • Does this answer your question? [How do I get the path to the current script with Node.js?](https://stackoverflow.com/questions/3133243/how-do-i-get-the-path-to-the-current-script-with-node-js) – TGrif Jan 07 '20 at 13:19

3 Answers3

1

Use process.cwd() which is also documented here: https://nodejs.org/api/process.html

Andre
  • 778
  • 1
  • 5
  • 23
0

This might solve your problem:

__dirname

Check with a console log whether it's what you wanted or not.

CrystalSpider
  • 377
  • 7
  • 16
0

There are multiple ways of achieving this. One of them is you can use this package,

app-root-path

Install the package with the command :

npm i -S app-root-path                   //install the package

Use package where you required :

var appRoot = require('app-root-path');  //require package 
console.log(appRoot);                    //use variable as string 

You can import the package and use variable where ever you require inside the app. You can check this package documentation visiting this link.

John
  • 972
  • 1
  • 7
  • 24