The location of the Node.js files depends on the method you have used to install it.
If you downloaded and run, the installer package from the nodejs.org website, the Node.js main executables files -- node and npm -- are located on the /usr/local/bin folder.
You can verify that the node and npm files are located at that location by running the following commands:
ls /usr/local/bin/node ls /usr/local/bin/npm
With this installation method the files will be be available to all users. Also, you may have needed to use 'sudo', or entered an administrator password, to install it.
Location of node modules:
Location of npm modules:
Other Folders and Files:
/usr/local/include/node (folder) /usr/local/lib/dtrace/node.d (file) /usr/local/lib/node_modules (folder) /usr/local/share/doc/node (folder) /usr/local/share/man/man1/node.1 (file) /usr/local/systemtap/tapset/node.stp (file)
If you used nvm to install node, the files are located on your home folder, specifically, on the ".nvm" hidden folder.
The structure (excerpt) is as follows:
~/.nvm └─ versions └─ node ├─ v11.14.0 │ └─ lib │ └─ node_modules │ └─ npm └─ v12.4.0 └─ lib └─ node_modules └─ npm
The nvm installation also creates a ".npm" hidden folder
And it created or updated the ~/.bash_profile file, with the following content:
export NVM_DIR="$HOME/.nvm" [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion