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

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

Related

'node --no-deprecation': No such file or directory when running global npm command in ubuntu docker container

I'm trying to install the npm package #stoplight/cli globally onto a docker image for use in a GitHub action. The docker image builds successfully, but when I call stoplight from /bin/bash with stoplight, I get the dreaded /usr/bin/env: 'node --no-deprecation': No such file or directory error.
I know there has been a lot of questions of this exact error, but so far none of the solutions have worked12.
I tried:
Creating symlink with ln -s /usr/bin/nodejs /usr/bin/node
Installing nodejs-legacy instead
My Dockerfile
FROM ubuntu:latest
RUN apt-get update
RUN curl -sL https://deb.nodesource.com/setup_12.x | bash -
RUN apt-get -y install git curl
RUN apt-get install -y nodejs
RUN npm install -g #stoplight/cli#3.0.1
ENTRYPOINT ["bash", "stoplight --version"]
EDIT: ** I also tried doing this with the official debian "node" image as base, and it was the same issue.
Any help appreciated
we've released a new version of the CLI that should hopefully resolve the issue for you. The following dockerfile should work!
FROM ubuntu:latest
RUN apt-get update
RUN apt-get -y install curl
RUN curl -sL https://deb.nodesource.com/setup_12.x | bash -
RUN apt-get install -y nodejs
RUN npm install -g #stoplight/cli#3.0.4
ENTRYPOINT ["stoplight"]

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.

Create ubuntu docker image with nodeJS 4

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.

Unable to install node 7.5.0

I am trying to install nodejs in a docker container
Using curl -sL https://deb.nodesource.com/setup_7.x | sudo -E bash -
as per the instructions on nodejs.org
But it seems to always install v 0.10.29
Will appreciate any help on this
Or you can just use the prebuilt node Docker image on DockerHub
RUN apt-get update
RUN apt-get install -y curl nodejs
RUN curl -sL https://deb.nodesource.com/setup_7.x | sudo -E bash

Error when adding generator-jhipster via YARN

I ran the following command to install the generator-jhipster via yarn:
yarn global add generator-jhipster
After doing so, I ran into the following issue:
The engine "node" is incompatible with this module. Expected version ">=6.9.5"
Any clue as to how I can get around this issue?
TIA
Install node 6.9.5 or more recent.
Update node to the latest version.
sudo npm cache clean -f
sudo npm install -g n
sudo n stable
Once your install is complete, you can confirm you version with another command:
node -v
To Download latest node
https://nodejs.org/en/download/package-manager/
Node.js v5:
curl -sL https://deb.nodesource.com/setup_5.x | sudo -E bash -
sudo apt-get install -y nodejs
Node.js v6:
curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
sudo apt-get install -y nodejs
Node.js v7::
curl -sL https://deb.nodesource.com/setup_7.x | sudo -E bash -
sudo apt-get install -y nodejs
Node.js v8::
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
sudo apt-get install -y nodejs
You can also try to use
yarn --ignore-engines

Resources