Ubuntu install puppeteer

Installing puppeteer into a fresh AWS EC2 Ubuntu 18.04 and its dependencies.

sudo apt update
sudo apt upgrade
sudo apt install npm
npm i puppeteer

Now run a simple puppeteer script and you will encounter errors about missing shared libraries. A simple script below, lets name it simple.js

const puppeteer = require('puppeteer');
async function run () {
   const browser = await puppeteer.launch({
      defaultViewport: {width: 1920, height: 1080}
   });
   const page = await browser.newPage();
   await page.goto('https://www.google.com/search?q=bitcoin');
   await page.screenshot({path: 'screenshot.png'});
   browser.close();
}
run(); 
node simple.js

Now install the dependencies and rerun.

sudo apt install libx11-xcb1 libxcomposite1 libxcursor1 libxdamage1 libxi-dev libxtst-dev libnss3 libcups2 libxss1 libxrandr2 libasound2 libatk1.0-0 libatk-bridge2.0-0 libpangocairo-1.0-0 libgtk-3-0

Ubuntu setup React Native

Ubuntu setup React Native

In this post, I am setting up React Native in Ubuntu 18.04. Before we begin, we need to check if we have all the prerequisites. Once all prerequisites are installed, we will proceed with setting up a React Native project. Finally running the app in Expo app in iOS and Android.

Java Development Kit (JDK)

Check your JDK version to see if you currently have JDK installed. In my screenshot, I do not have JDK installed.

# Check if you have JDK installed
javac -version

# Run the below command to install JDK
sudo apt install openjdk-8-jdk-headless

ubuntu setup react native
JDK not found in my Ubuntu 18.04.

Python

Check your python version to see if you had python installed.

# Check your python version
python -v

# Run the below command to install python
sudo apt install python

ubuntu setup react native
Python not found in my Ubuntu 18.04.

Node.js and npm

Check your Node.js and npm version to see if you had it installed.

# Check Node.js version
node -v

# Check npm version
npm -v

# Install Node.js
sudo apt install nodejs

# Install npm
sudo apt install npm

ubuntu setup react native
Node.js and npm not found in my Ubuntu 18.04.

Create React Native project

# This is for generating React Native project files
sudo npm install -g create-react-native-app

# Create a new project MyReactNativeApp
sudo create-react-native-app MyReactNativeApp

ubuntu setup react native
Successfully created MyReactNativeApp project.

Setting Permissions

Earlier we created the React Native project with sudo because it needs to write some files into /usr/local/ directory. Now we need to change the project files owner back to myself.

# Changeing the owner from root to myself
cd ~
sudo chown -R kevinfoo:kevinfoo .expo/
sudo chown -R kevinfoo:kevinfoo MyReactNativeApp/

Running the app

cd MyReactNativeApp
expo start

ubuntu setup react native
Successfully starting the app.

ubuntu setup react native
Install the Expo client in iOS or Android and scan the QR code to run it.

Expo client

Expo client is available for download at their official site.