LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Installing different versions of nodejs (https://www.linuxquestions.org/questions/linux-newbie-8/installing-different-versions-of-nodejs-4175594320/)

NotionCommotion 11-27-2016 12:01 PM

Installing different versions of nodejs
 
Per https://nodejs.org/en/download/packa...nux-and-fedora, I am trying to install nodejs version 6 and npm on Centos6.

When I check the version of the installed package, it appears that it is some old version 0.10.46. But if I google "0.10.46-1.el6 nodejs", it appears not to be that old.

What version of nodejs have I installed? If old, how do I install a newer version?

Thanks


Code:


[root@devserver ~]# curl --silent --location https://rpm.nodesource.com/setup_6.x | bash -

## Installing the NodeSource Node.js 6.x repo...


## Inspecting system...

+ rpm -q --whatprovides redhat-release || rpm -q --whatprovides centos-release || rpm -q --whatprovides cloudlinux-release || rpm -q --whatprovides sl-release
+ uname -m

## Confirming "el6-x86_64" is supported...

+ curl -sLf -o /dev/null 'https://rpm.nodesource.com/pub_6.x/el/6/x86_64/nodesource-release-el6-1.noarch.rpm'

## Downloading release setup RPM...

+ mktemp
+ curl -sL -o '/tmp/tmp.ZO59oc8RTf' 'https://rpm.nodesource.com/pub_6.x/el/6/x86_64/nodesource-release-el6-1.noarch.rpm'

## Installing release setup RPM...

+ rpm -i --nosignature --force '/tmp/tmp.ZO59oc8RTf'

## Cleaning up...

+ rm -f '/tmp/tmp.ZO59oc8RTf'

## Checking for existing installations...

+ rpm -qa 'node|npm' | grep -v nodesource

## Run `yum install -y nodejs` (as root) to install Node.js 6.x and npm.
## You may also need development tools to build native addons:
##  `yum install -y gcc-c++ make`

[root@devserver ~]# yum install -y nodejs npm
Loaded plugins: fastestmirror, priorities, security
Setting up Install Process
Loading mirror speeds from cached hostfile
 * base: mirror.tocici.com
 * epel: linux.mirrors.es.net
 * extras: mirror.pac-12.org
 * ius: mirrors.kernel.org
 * updates: centos.mirror.ndchost.com
183 packages excluded due to repository priority protections

......                                                                                                                                                                                      75/75

Installed:
  nodejs.x86_64 0:0.10.46-1.el6                                                                                          npm.noarch 0:1.3.6-5.el6

Dependency Installed:
.....

Complete!
[root@devserver ~]#

[root@devserver ~]# node -v
v0.10.46
[root@devserver ~]# npm -v
1.3.6
[root@devserver ~]#


sundialsvcs 11-27-2016 12:35 PM

Although a package might install one particular version of this JavaScript library (and might uninstall older ones from its appointed location for such things), bear in mind that this library will be used by clients of web sites hosted by this machine ... each client requesting the library from the server through some URL.

And so, there's nothing in this world keeping you from downloading other versions of this library, directly from its authoritative source, and placing these different versions where this-or-that web site will know to find it. (Probably abstracting those locations to the client through the use of Apache <Directory> or <Location> tags.)

Also consider carefully how you choose to specify the caching behavior of this (rather large, even when minified) library file. You want to encourage the client browser to cache it, without losing the ability to supersede their cached copy.

Note that it is not recommended to attempt to source the library directly from nodejs.org, nor from any other "external" source. You should have copies on the server machine of "anything and everything which this server will be tasked to deliver to a client."

- - -
Incidentally: this reply applies equally to any host operating system, and/or any web-server software.

NotionCommotion 11-27-2016 12:53 PM

Hi sundialsvcs,

Node.js is a little (make that a lot) different than tradition JavaScript. Particularly, it is executed by the server and not the web browser client, and it is not a single file called Node.js, but that is the name of the entire environment.

Thanks


All times are GMT -5. The time now is 04:03 AM.