Error: Server terminated early with status 127. How to solve this? - node.js

I am trying to run this file in a docker container (I also leave the dockerfile after the error) and I can't figure out the reason for this error.
Error:
$ node main.js
Webdriver started
/Discord-Screenshare/node_modules/selenium-webdriver/remote/index.js:248
reject(Error(e.message))
^
Error: Server terminated early with status 127
at /Discord-Screenshare/node_modules/selenium-webdriver/remote/index.js:248:24
at processTicksAndRejections (node:internal/process/task_queues:96:5)
Node.js v17.9.0
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
The command '/bin/sh -c yarn start' returned a non-zero code: 1
Dockerfile:
FROM ubuntu:20.04
# Install dependencies
RUN apt-get update
RUN apt-get install -y curl git unzip wget
RUN DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC apt-get -y install tzdata
RUN curl -fsSL https://deb.nodesource.com/setup_17.x | bash -
RUN apt-get install -y nodejs
RUN npm i -g yarn
# Clone Repo
RUN git clone https://github.com/MainSilent/Discord-Screenshare.git
WORKDIR Discord-Screenshare
RUN yarn install
COPY .env .
# Install chrome 88
RUN wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
# Install chromedriver 88
RUN wget https://chromedriver.storage.googleapis.com/88.0.4324.27/chromedriver_linux64.zip
RUN unzip chromedriver_linux64.zip
RUN mv chromedriver /bin
# Start Bot
RUN yarn start
I tried installing the latest version of google chrome drivers for linux and also checked if selenium was at the latest version.

Related

Web app not accessible while using yarn in docker

I am trying to run a web app inside docker via yarn. Here's the docker file
FROM ubuntu:20.04
ARG DEBIAN_FRONTEND=noninteractive
RUN apt-get update -y && apt-get upgrade -y
ENV TZ=Pacific/Auckland
RUN echo $TZ > /etc/timezone && ln -snf /usr/share/zoneinfo/$TZ /etc/localtime
RUN apt-get install curl -y
RUN apt-get install npm -y
RUN apt-get install git -y
RUN npm cache clean -f
RUN npm install -g n
RUN n stable
RUN apt remove cmdtest -y
RUN apt remove yarn -y
RUN npm install -g yarn -y
RUN git config --global url."https://".insteadOf git://
EXPOSE 8080
COPY . .
RUN yarn
CMD yarn start
When I run yarn start as a non-docker the web app is accessible via localhost:8080
However when I start the docker instance via docker run -p 8080:8080 -itd webapp:latest & launch web browser & type in http://localhost:8080 the webapp isn't accessible.
Running docker logs against the container doesn't show any errors.
When I run curl, here is the error I see
curl "http://localhost:8080"
curl: (56) Recv failure: Connection reset by peer
I've no clue what is going on. Please could I request help to fix this problem.
the IP had to be bound on multiple interfaces for this to start working

'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"]

Docker with Node.js and Express.js

I'm trying to use docker with my node application, my Dockerfile looks like this:
RUN apt-get update
RUN apt-get -y install build-essential
RUN apt-get install -y nodejs
RUN apt-get install -y npm
ADD . /src
RUN cd /src && npm install
EXPOSE 8080
CMD ["node","/src/app.js"]
but after running docker build when npm install is running after trying to install https://registry.npmjs.org/wordwrap/-/wordwrap-0.0.2.tgz I get an error:
The command 'bin/sh -c /src && npm install' returned a non-zero code : 1
What can cause such an issue? I've already tried to install node-legacy instead of node and it didn't work
Try this:
# put this line on your code (if you are using ubuntu)
# this make a link from nodejs to node to add compatibility on ubuntu OS
RUN ln -s /usr/bin/nodejs /usr/bin/node
# set your current directory with WORKDIR
WORKDIR /src
RUN sudo npm install

Issue running Gulp on Docker

I have the following Dockerfile
FROM debian:jessie
MAINTAINER Ewan Valentine <ewan#theladbible.com>
WORKDIR /tmp
RUN apt-get update -y && \
apt-get install -y \
curl
RUN curl --silent --location https://deb.nodesource.com/setup_0.12 | bash -
RUN apt-get install --yes nodejs
VOLUME ["/var/www/admin/src"]
RUN mkdir -p /var/www/admin/src
WORKDIR /var/www/admin/src
RUN npm install -g gulp
ENTRYPOINT ["gulp"]
However, when I run $ docker-compose run gulp I get the following error:
[10:47:49] Local gulp not found in /var/www/admin/src
[10:47:49] Try running: npm install gulp
I'm using docker-compose and this container is linked to a volume where the source code is kept, which all runs fine otherwise.
I was liking to the wrong volume! Sorted now.

Getting error installing nodejs when building from docker

I am trying to install nodejs using the docker console for ubuntu but I get an error installing node js. This is the error I am getting
The command [/bin/sh -c ./configure && make && make install] returned a non-zero code: 127
This is part of my dockerfile
FROM ubuntu:12.04
RUN mkdir -p /dir/subdir
RUN apt-get update
# Install nodejs
ADD http://nodejs.org/dist/v0.10.26/node-v0.10.26-linux-x64.tar.gz /dir
WORKDIR /dir/node-v0.10.26-linux-x64
RUN ./configure && make && make install
WORKDIR /dir
Exit code 127 typically means "command not found". Chances are build-essentials are not installed.
Try adding the following after the apt-get update:
RUN apt-get -y install build-essential

Resources