6

I want to see my all packages and modules of node-module. Please tell me its the location in ubuntu 18.04. such as /path/to/node-module. Moreover, How to see the code of modules such as http module or fs module.

3 Answers 3

7

Global libraries

You can run npm list -g to see which global libraries are installed and where they're located. Use npm list -g | head -1 for truncated output showing just the path.

On Unix systems they are normally placed in /usr/local/lib/node or /usr/local/lib/node_modules when installed globally. If you set the NODE_PATH environment variable to this path, the modules can be found by node.

Non-global libraries

Non-global libraries are installed the node_modules sub folder in the folder you are currently in. You can run npm list to see the installed non-global libraries for your current location.

1
  • 1
    Thank You for your help...... Commented Nov 17, 2019 at 3:50
3

You can see the local location like this:

$ npm root
/home/<user>/<path>/node_modules

and the global location like this:

$ npm root -g
/usr/lib/node_modules
1

node_modules installed globally are rooted in the library where sudo admin is necessary to access

/usr/local/lib/node_modules

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .