11

I am a newbie with Linux general, and here's what I am trying to achieve:

I am trying to install nodejs version on Debian Linux with the following command:

apt-get install nodejs=8.14.0

But I get this error in return:

E: Version '8.14.0' for 'nodejs' was not found

As far as I found, this is the correct way to specify a version. If I do this, then it works fine:

apt-get install nodejs

But I need this specific version, and not the latest one. I am doing this for a Docker image, so it has to be installed at runtime.

1

3 Answers 3

11

Make sure you have the following packages:-

sudo apt-get install \
    apt-transport-https \
    curl \
    software-properties-common

Enable the NodeSource repository by using a command:-

sudo curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -

After enabling the repository, install Node.js using a command:-

sudo apt-get install nodejs
2
1

If you're doing this for a Docker image, why not just use the Node Docker image with the version you need?

9
  • Because I need to make a custom image with specific java and gradle versions. Feb 5, 2020 at 23:00
  • It sounds like you're going about building the Docker image the wrong way then, to be honest. What is it you're trying to accomplish? Because if it's to build something, maybe we can help you evaluate your approach, rather that installing all of this into a single container.
    – user344450
    Feb 7, 2020 at 18:49
  • I want to create one image, that I can re-create everytime on a build that will use specific Java, Gradle, Node etc. versions in that image. Either this image will be re-built everytime or I can keep it in a private repo and re-use it. Please let me know if this seems wrong, I am new to Docker. Feb 7, 2020 at 20:20
  • So I guess the question is what are you trying to do with all of that, though? Build some kind of containerized CI system? Build a node project? Build and host a Node project? Without knowing what you're trying to do, it makes it tough to advise, but in general installing a bunch of stuff like you're describing sounds like an anti-pattern.
    – user344450
    Feb 10, 2020 at 16:32
  • 1
    I'd start here, and then post more to SO if you have questions! docs.docker.com/develop/develop-images/multistage-build
    – user344450
    Feb 17, 2020 at 19:05
0

You can try installing your node using a package manager like nvm:

Installing Node.js to linux

Or download the binaries directly from here: Node.js v8.14.0

2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.