The npm community forum has been discontinued.
To discuss usage of npm, visit the GitHub Support Community.
How to get the location of the package installed globally
I have an npm package https://npmjs.com/package/@buildtip/create-web-app where the main file is running when the package is run is
dist/cli.js. Now, this file needs to get a file from one upper directory. The method I implemented in node is
But this is checking from in the folder from where the command is running or from the location of the user’s terminal. Not from where this package is installed.
This is the code for the package. link
I want a node method or something which can get me the location of the project installed (global location as it is global package) not the location from where it is called.
You can use
__dirname which gives you directory of current module. Something like:
Thanks Again . This one is working fine .