Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
616 views
in Technique[技术] by (71.8m points)

node.js - Docker container gives No binary for Chrome browser on your platform

I'm running Angular unit tests in a Docker container and getting this error:

21 01 2021 01:51:10.057:INFO [launcher]: Launching browsers ChromeHeadless with concurrency unlimited
21 01 2021 01:51:10.063:INFO [launcher]: Starting browser Chrome
21 01 2021 01:51:10.097:ERROR [launcher]: No binary for Chrome browser on your platform.
  Please, set "CHROME_BIN" env variable.

To run the tests I am simply running .. ng test .. using the image node:14 from Docker Hub

Is there an almost identical (preferably official) image that I can use that also has Chrome all ready to go on it?

question from:https://stackoverflow.com/questions/65837359/docker-container-gives-no-binary-for-chrome-browser-on-your-platform

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I had to run this on build server:

wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add -
echo "deb http://dl.google.com/linux/chrome/deb/ stable main" > /etc/apt/sources.list.d/google.list
apt-get update
apt-get install -y google-chrome-stable xvfb
npm i -g @angular/cli

All the instructions except the last install Chrome. The last installs Angular and is not needed if you are not using Angular.

NOTE: I had to have Chrome installed because ng test uses Chrome - however, I've since switched to Jest which I believe can run unit tests without Chrome installed - although I haven't checked this.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...