Created
May 31, 2018 21:01
-
-
Save ceberous/a5c23d5f21fdbd034ebe89d77fc3e51d to your computer and use it in GitHub Desktop.
Returns Node Global Path
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const cp = require( "child_process" ); | |
| function get_node_global_path() { | |
| try { | |
| const output = cp.spawnSync( "npm" , [ "root" , "-g" ] , { encoding : "utf8" } ); | |
| return output.stdout.trim(); | |
| } | |
| catch( error ) { console.log( error ); process.exit( 1 ); } | |
| } | |
| const NodeGlobalPath = get_node_global_path(); | |
| // const path = require( "path" ); | |
| // const request = require( path.join( NodeGlobalPath , "request" ) ); | |
| // const cheerio = require( path.join( NodeGlobalPath , "cheerio" ) ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment