Create ubuntu docker image with nodeJS 4 - node.js

I need to create a ubuntu docker image with nodeJS 4. What I was doing is this:
FROM ubuntu:16.04
RUN apt-get update -y && \
apt-get install -yqq python build-essential apt-transport-https ca-certificates curl locales nodejs npm sudo git
RUN curl -sL https://deb.nodesource.com/setup_4.x | bash -
RUN update-alternatives --install /usr/bin/node node /usr/bin/nodejs 10
But does that make sense at all? Installing apt-get install nodejs npm and curl -sL https://deb.nodesource.com/setup_4.x | bash -
And also I have to do update-alternatives --install /usr/bin/node node /usr/bin/nodejs 10
I would like to get this a bit smaller and smarter.

Here is how I install nodejs in a Debian Jessie container :
COPY ./rsrc/nodesource.gpg.key /tmp/nodesource.gpg.key
RUN apt-key add /tmp/nodesource.gpg.key
RUN echo 'deb https://deb.nodesource.com/node_6.x jessie main' > /etc/apt/sources.list.d/nodejs.list
RUN apt-get update
RUN apt-get install -y nodejs
I think adding the offical repo list to apt is the best option here.
Edit :
The first two lines add the crypto nodesource key to apt (used later to crypto verify pkg), then add node list to you apt list, update and install your node package
Edit² :
Also, add a dedicated default user into you node image.

Related

Not able to install Node 10.x version in docker container

I have all the code to install nodejs 10.x verison inside ubuntu docker file, but its listing only the old version when am using node -v and not the latest one. PFB the dockerfile for more understanding
FROM selenium/node-chrome-x.x.x
RUN curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -
RUN apt-get install nodejs
RUN sudo ln -s /usr/bin/nodejs /usr/local/bin/node
RUN node -v
Expected output
Node version 10.x
Actual output
Node Version is 4.86
Please let us know how to setup the latest nodejs version and use it for other tool setup
I have modified your Dockerfile and used image that you require. I had to install some dependencies like curl and so on. Also I just run one RUN command to create less intermediate layers :
FROM selenium/node-chrome:2.53.1
RUN sudo apt-get update &&\
sudo apt-get -y install curl &&\
curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash - &&\
sudo apt-get -y install nodejs &&\
sudo ln -s /usr/bin/nodejs /usr/local/bin/node
RUN node -v
The output is :
v10.16.0

How To Install Node Js In Ubuntu 18.10?

i'm trying to install nodejs in Ubuntu 18.10 but it returns some error.
The following packages have unmet dependencies:
nodejs : Depends: python-minimal but it is not going to be installed
E: Unable to correct problems, you have held broken packages.
Above is the message i get while install node Js by cammand: sudo apt-get install nodejs.
As described in this link:
Install node version manager:
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.32.0/install.sh | bash
Activate nvm:
. ~/.nvm/nvm.sh
Use nvm to install the version of node you want:
nvm install 4.4.5
Test that Node.js is installed:
node -e "console.log('Running Node.js ' + process.version)"
The recommended way to install node under Ubuntu appears to be to use the archives provided by NodeSource.
Their instructions are to run these shell commands to, presumably, set up a PPM and install a current version of node from that source.
curl -fsSL https://deb.nodesource.com/setup_16.x | sudo -E bash -
sudo apt-get install -y nodejs
First you need to install python 2.7 using following commands
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt-get update
sudo apt-get install python2.7
then install nodejs
sudo apt-get install nodejs
Using Ubuntu
curl -fsSL https://deb.nodesource.com/setup_15.x | sudo -E bash -
sudo apt-get install -y nodejs
Using Debian, as root
curl -fsSL https://deb.nodesource.com/setup_15.x | bash -
apt-get install -y nodejs

Trouble installing NodeJS on Kali Linux docker image

I am trying to create a docker image based on the Kali Linux base image, and I need to install NodeJS as a dependency for my application.
Here's my Dockerfile:
FROM kalilinux/kali-linux-docker
RUN apt-get update -y && \
apt-get dist-upgrade -y && \
apt-get autoremove -y && \
apt-get clean -y
RUN apt-get install curl -y
RUN curl --silent --location https://rpm.nodesource.com/setup_8.x | bash - \
&& apt-get install nodejs -y
RUN npm i -g npm
ENV NODE_ENV production
WORKDIR /root/app
COPY . .
RUN npm i
EXPOSE 4000
ENTRYPOINT ["npm", "start"]
However, I hit the following error trying to install NodeJS:
Step 4/11 : RUN curl --silent --location https://rpm.nodesource.com/setup_8.x | bash - && apt-get install nodejs -y
---> Running in a63e56802eba
## Installing the NodeSource Node.js 8.x LTS Carbon repo...
## Inspecting system...
## You don't appear to be running an Enterprise Linux based system,
please contact NodeSource at https://github.com/nodesource/distributions/issues
if you think this is incorrect or would like your distribution to be considered
for support.
The command '/bin/sh -c curl --silent --location https://rpm.nodesource.com/setup_8.x | bash - && apt-get install nodejs -y' returned a non-zero code: 1
Admittedly I'm confused by a few things... namely that I was under the impression that NodeJS was already installed on Kali Linux (I have a VirtualBox VM using Debian 64-bit where it exists). I went as far as trying to install the kali-linux-all metapackage, but NodeJS/npm don't seem to exist.
Am I simply misunderstanding some basic premise of Docker and/or Kali Linux? Is there any other way to install NodeJS into my container?
I still don't fully understand why NodeJS is installed on my VM but not the base Kali docker image... but in any case I did manage to unblock myself.
First, I was pulling down a NodeJS installation script from nodesource which required rpm -- I found a different script that works without it. However the new script also required that I install gnupg.
Here's my updated Dockerfile:
FROM kalilinux/kali-linux-docker
RUN apt-get update -y && \
apt-get dist-upgrade -y && \
apt-get autoremove -y && \
apt-get clean -y
RUN apt-get -y install curl gnupg
RUN curl --silent --location https://deb.nodesource.com/setup_8.x | bash - \
&& apt-get install nodejs -y
RUN npm i -g npm
ENV NODE_ENV production
WORKDIR /root/app
COPY . .
RUN npm i
EXPOSE 4000
ENTRYPOINT ["npm", "start"]

Package 'npm' has no installation candidate

I want to install npm in Debian 9.
I've tried:
apt-get install nodejs
completely installed and nodejs -v results: v4.8.2.
but when try to run npm an error says:
bash: npm: command not found
Base on my searches I've tried other ways:
based on this guide: https://www.godaddy.com/help/install-nodejs-ubuntu-17395 I've tried:
sudo apt-get install npm
results:
E: Package 'npm' has no installation candidate
Based on another guide I've tried:
wget https://npmjs.org/install.sh
sudo chmod +x install.sh
sudo ./install.sh
results:
npm cannot be installed without node.js.
of course I've installed nodejs. I also tried this way:
curl --silent --location https://deb.nodesource.com/setup_0.12 | sudo bash -
sudo apt-get update
sudo apt-get install --yes nodejs
It says:
nodejs is already the newest version (4.8.2~dfsg-1).
What should I do?
Remove the old version
sudo apt-get purge nodejs
Install the new version:
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
sudo apt-get install -y nodejs
Alternatively, for Node.js 9:
curl -sL https://deb.nodesource.com/setup_9.x | sudo -E bash -
sudo apt-get install -y nodejs
Source
It might tell you that you are missing package gnupg2, just install it.

I can not install the nodejs 6 on ubuntu

At first I installed the node with terminal, with command
Update Package Manager
sudo apt-get update
Adding NodeJS PPAs
sudo apt-get install python-software-properties
curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
Installing NodeJS and NPM
sudo apt-get install nodejs
It works, but when I am looking version node, I see node v 4
Then I used google for search this problem and a found this topic
https://stackoverflow.com/a/43914369
There using a ln command for create symbolic link between two files
and used this instruction for manual install, but nothing happens, error appears and not installing
Look at this screenshot
Maybe I doing anything wrong?
I tend to avoid using my operating system's package manager to install node. The easiest way to install node is Node Version Manager.
Yeah! The solutions found in official site
Of course link Install node version 6
Can you please check:
curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
sudo apt-get install -y nodejs
sudo apt-get install -y build-essential
but for this you need curl to be installed.
sudo apt-get update
To install curl: sudo apt-get install curl
Here's the link for this.
To upgrade node to latest version: https://askubuntu.com/questions/426750/how-can-i-update-my-nodejs-to-the-latest-version#480642

Resources