How do I check if the Node was installed?

Hello.

I have built an image with Dockerfile, it looks like this:

FROM node:12.18.1
USER root
RUN apt-get -y update 
RUN apt-get -y install curl 
RUN npm install 
ENTRYPOINT ["curl"]

Now I can see that curl is installed, but how can I check on Node? Every time I am trying to see the version I get an error:

'node'/'npm' is not recognized as an internal or external command,

I also tried this:

docker run -it --rm node /bin/bash -c 'node --version'

but ended up with this:

--version': -c: line 1: unexpected EOF while looking for matching `''
--version': -c: line 2: syntax error: unexpected end of file

Does any one know how to do it? Thanks.

Did you share the exact same Dockerfile that you used?

As far as I know npm install would need a file with the dependencies to install them. How do you create that file and copy to the image?

The error message also indicates there is something more in the image. For example a wrong entrypoint.

If the official image gives you that error message, it is possible that you created an image with the same name as the official image. If I run that command it works for me. It pulls the official image from Docker Hub.

Hello,

actually, there are some commented fields in the file + I already built some other instruments like curl so I changed the FROM as well.

now the file looks like this

#FROM jenkins/inbound-agent:latest
FROM node:12.18.1


USER root


ENV NODE_VERSION=16.17.0 \
    curl_version=7.87.0 \
    sonarscanner_version=4.8.0.2856
    #sonarqube_version=8.9.10-developer
   
#RUN sudo apt update && sudo apt install curl -y 
RUN apt-get -y update 
RUN apt-get -y install curl 
RUN npm install 
  #&& curl -s -L https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-3.3.0.1492-linux.zip -o sonarscanner.zip \
  #&& unzip -qq sonarscanner.zip \
  #&& rm -rf sonarscanner.zip \
  #&& mv sonar-scanner-3.3.0.1492-linux sonar-scanner
  

ENTRYPOINT ["curl"]

#CMD [ "node", "server.js" ]

#RUN npm --version

looks like or this is exactly the same as you run? :slight_smile:

npm install still doesn’t make sense without a package.json andnow. Using the commands you shared so far I can’t reproduce the issue. The only thing I can see is that you changed the entrypoint to curl which again, doesn’t make sense in a node js container and any argument that you pass to docker run after the image name will be the argument of curl.

well there are a couple more rows with # at the beginning (those comments are not in English so I didn’t copy them)

so as far as I understood I have to install json package first, correct?

The lack of the package.json is just one thing I noticed and has nothing to do with the argument related error message.I shared some of my ideas, but unless you can react to those ideas I don’t have more.

The shared Dockerfile can’t produce the error messages unless you overwrote some images. You can try to pull everything again.

actually I did overwrite
I was building curl from jenkins, and now its npm from node