Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

docker, nodejs: node not found error

(on Ubuntu 16.04 and Docker 1.13)

When I run my dockerfile that tries to run my server.js, I get an error:

sh: 1: node: not found

I did some research and the name node and nodejs got changed because of package conflicts and is causing the error; however, when I switch to nodejs-legacy is doesn't work. What is causing the issue?

error with nodejs

error with nodejs-legacy


DockerFile

FROM ubuntu
RUN apt-get update
RUN apt-get install nodejs -y 
#RUN rm -f package-lock.json
RUN apt-get install npm -y
RUN apt-get install apt-utils -y

WORKDIR /usr/scr/app

COPY package.json package-lock.json /usr/src/app/
COPY . .

EXPOSE 8080
CMD ["npm", "start"]

package.json

{
 "name": "iam",
 "version": "1.0.2",
 "description": "Identity and access management.",
 "main": "server.js", 
 "scripts": {"start": "node server.js" },
 "author": "",
 "license": "ISC",

 "dependencies": {
    "body-parser": "^1.17.2",
    "cors": "^2.8.3",
    "express": "^4.15.3",
    "jsonwebtoken": "^7.4.1",
    "ldapjs": "^1.0.1"
  }
}
like image 491
ComputerGuy123 Avatar asked Mar 02 '26 10:03

ComputerGuy123


1 Answers

Make sure to have a comma in between the CMD command array

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

instead of

CMD ["node" "server.js"] 
like image 189
Rishab Surana Avatar answered Mar 05 '26 00:03

Rishab Surana



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!