Bootstrap FreeKB - NodeJS - Install NodeJS on Linux
NodeJS - Install NodeJS on Linux

Updated:   |  NodeJS articles

The wget command can be used to download the NodeJS installation tar from https://nodejs.org/en/download to your Linux system that wil be running NodeJS. This will download a file such as node-v20.10.0-linux-x64.tar.xz.

wget https://nodejs.org/dist/v20.10.0/node-v20.10.0-linux-x64.tar.xz

 

Create a directory for NodeJS.

mkdir --parents /usr/local/nodejs

 

Then use the tar command to extract the file. In this example, NodeJS will be extracted to the /usr directory.

tar -xpf node-v20.10.0-linux-x64.tar.xz --directory /usr/local/nodejs

 

You can now delete the tar.xz file you downloaded.

rm node-v20.10.0-linux-x64.tar.xz

 

Let's create a symbolic link from /usr/bin/node to /usr/local/nodejs/node-v20.10.0-linux-x64/bin/node (in this example) so that the node command is in our $PATH (since CLIs in the /usr/bin directory should be in our $PATH) so that we can just use the node command and not the full path to the node CLI.

ln -s /usr/local/nodejs/node-v20.10.0-linux-x64/bin/node /usr/bin/node

 

You should now be able to use the npm command, which is located at /opt/nodejs/bin/npm. 

 ~]# npm --help

Usage: npm <command>

where <command> is one of:
    access, adduser, audit, bin, bugs, c, cache, ci, cit,
    clean-install, clean-install-test, completion, config,
    create, ddp, dedupe, deprecate, dist-tag, docs, doctor,
    edit, explore, fund, get, help, help-search, hook, i, init,
    install, install-ci-test, install-test, it, link, list, ln,
    login, logout, ls, org, outdated, owner, pack, ping, prefix,
    profile, prune, publish, rb, rebuild, repo, restart, root,
    run, run-script, s, se, search, set, shrinkwrap, star,
    stars, start, stop, t, team, test, token, tst, un,
    uninstall, unpublish, unstar, up, update, v, version, view,
    whoami

npm <command> -h  quick help on <command>
npm -l            display full usage info
npm help <term>   search for help on <term>
npm help npm      involved overview

Specify configs in the ini-formatted file:
    /root/.npmrc
or on the command line via: npm <command> --key value
Config info can be viewed via: npm help config

npm@6.14.13 /opt/nodejs/lib/node_modules/npm

 

 

 

 

 




Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee



Comments


Add a Comment


Please enter 449786 in the box below so that we can be sure you are a human.