Installation notes for ubuntu18


reference resources

  • QQ group – Javascript advanced crawler – author self built group, welcome to join!
  • Awesomejava crawler – the crawler related tools and materials collected by the author
  • A script to help you automatically create alicloud preemptive instances and enable network acceleration – automatically create alicloud overseas preemptive nodes
  • Install on CentOS node.js Binary distribution package – install nodejs latest version on CentOS
  • Centos7 simplest installation notes for puppeter – install puppeter on CentOS


I have tried to install puppeter on centos7 and make it start normally in headless mode and display Chinese font correctly.
Today, I tried to achieve the same goal on the ubuntu18, so I will not forget it later.


  1. Install nodejs, same as centos7, omitted
  2. Installation of cnpm, omitted
  3. To install the puppeter, use thecnpm install puppeteerthat will do
  4. According to the wiki article on the puppeter project home page, use the following command to install the missing libraries:

    apt-get install -y gconf-service libasound2 libatk1.0-0 libatk-bridge2.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 ca-certificates fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils
  5. At this point, chrome can be booted headless, but the Chinese font is displayed as a square, because the Chinese font is not included in the image. At this time, you need to move several commonly used fonts from windows to Ubuntu

    • Browse to the Windows font directoryC:\Windows\Fonts
    • Upload several commonly used fonts, such as “song style regular”, “Microsoft YaHei”, to the Ubuntu/usr/share/fontsDirectory, file name:simsun.ttc, msyh.ttc
    • Install several font toolssudo apt-get -y install fontconfig xfonts-utils
    • Create the font index information, update the font cache, and execute the following commands in sequence:

      1. mkfontscale
      2. mkfontdir
      3. fc-cache
    • implementfc-list :lang=zhList the Chinese fonts of the system. You should see several Chinese fonts at this time

At this point, the installation is complete and can be verified.

Validation (same as CentOS steps)

  • to write index.js The contents are as follows:

    const puppeteer = require('puppeteer');
    (async () => {
      const browser = await puppeteer.launch({args: ['--no-sandbox', '--disable-setuid-sandbox']});
      const page = await browser.newPage();
      await page.goto('');
      await page.screenshot({path: 'sf.png'});
      await browser.close();

    be careful:
    1) Must be added--no-sandboxParameter to start chrome, otherwise an error is reported
    2) The default is to start chrome in headless (no interface) mode--headlessparameter

  • node index.jsIf you execute the above script, it will generate a screenshot of the homepage in the current directory. You can open the screenshot file and have a look at it to verify whether Chinese can be displayed normally