How to Install and Setup a React App on Ubuntu 18.04.1

Image is loading...
React Native6 Comments on How to Install and Setup a React App on Ubuntu 18.04.1

How to Install and Setup a React App on Ubuntu 18.04.1

Install and Setup a React App on Ubuntu 18.04.1 LTS Bionic Beaver | React is a JavaScript library for building user interfaces. It is maintained by Facebook and a community of individual developers and companies. React can be used as a base for the development of single-page or mobile applications. It is a powerful library to deal with complex projects in an easy manner. React Native, one of the most lovable hybrid mobile application development frameworks is also based on React. Here I am going to explain the installation and set up of a React App on Ubuntu platform.




1. INSTALL NODEJS

Since React is a JavaScript library, it requires to have Nodejs(A JavaScript runtime) installed. 10.x is the current latest version of Node. Installation of Node.js can be done using the below command.

curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -
sudo apt-get install -y nodejs

2. INSTALL NPM

NPM(Node Package Manager) is needed to create a react app and it will be installed with the Nodejs installation itself. However, you can install the latest version for npm using the below command.

sudo npm install [email protected] -g




3. INSTALL REACT

Now you can install React using npm. You don’t need to worry about the complexity of React installation. create-react-app npm package will take care of it.

npm install -g create-react-app

4. CREATE A NEW REACT PROJECT

After successful installation of React, you can create a new app using create-react-app. awesome-project is the name I choose for my project

create-react-app awesome-project
Note:-

You can also combine the steps 3 and 4 with a single command using npx ( package runner tool that comes with npm 5.2+).

npx create-react-app awesome-project

Here npx will install react and creates a new app named awesome-project.




5. CHOOSING THE CODE EDITOR

You can choose your own favorite code editor for editing your project. But in my case, I choose Visual studio Code(VS code). Using the below link, you can download VS code for Ubuntu and install.

https://code.visualstudio.com

6. DIRECTING TO YOUR PROJECT FOLDER AND EDITING

Open your new project on VS code using the below command.

cd awesome-project
code .




7. RUNNING YOUR APPLICATION

The app you created can be run using the command below.

npm start

This opens up a new tab on your browser with the URL below.

http://localhost:3000

Have a nice code!

Hi, I'm Syamlal, the co-founder of Redmonark. I'm a developer, writer and also have a little bit of experience in graphic designing.

6 thoughts on “How to Install and Setup a React App on Ubuntu 18.04.1

  1. There might be a problem with the project dependency tree.
    It is likely not a bug in Create React App, but something you need to fix locally.

    The react-scripts package provided by Create React App requires a dependency:

    “webpack”: “4.29.6”

    Don’t try to install it manually: your package manager does it automatically.
    However, a different version of webpack was detected higher up in the tree:

    /node_modules/webpack (version: 3.10.0)

    Manually installing incompatible versions is known to cause hard-to-debug issues.

    If you would prefer to ignore this check, add SKIP_PREFLIGHT_CHECK=true to an .env file in your project.
    That will permanently disable this message but you might encounter other issues.

    To fix the dependency tree, try following the steps below in the exact order:

    1. Delete package-lock.json (not package.json!) and/or yarn.lock in your project folder.
    2. Delete node_modules in your project folder.
    3. Remove “webpack” from dependencies and/or devDependencies in the package.json file in your project folder.
    4. Run npm install or yarn, depending on the package manager you use.

    In most cases, this should be enough to fix the problem.
    If this has not helped, there are a few other things you can try:

    5. If you used npm, install yarn (http://yarnpkg.com/) and repeat the above steps with it instead.
    This may help because npm has known issues with package hoisting which may get resolved in future versions.

    6. Check if /node_modules/webpack is outside your project directory.
    For example, you might have accidentally installed something in your home folder.

    7. Try running npm ls webpack in your project folder.
    This will tell you which other package (apart from the expected react-scripts) installed webpack.

    If nothing else helps, add SKIP_PREFLIGHT_CHECK=true to an .env file in your project.
    That would permanently disable this preflight check in case you want to proceed anyway.

    P.S. We know this message is long but please read the steps above 🙂 We hope you find them helpful!

    npm ERR! code ELIFECYCLE
    npm ERR! errno 1
    npm ERR! [email protected] start: `react-scripts start`
    npm ERR! Exit status 1
    npm ERR!
    npm ERR! Failed at the [email protected] start script.
    npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

    npm ERR! A complete log of this run can be found in:

    1. There might be a problem with the project dependency tree.
      It is likely not a bug in Create React App, but something you need to fix locally.

      1. Delete package-lock.json (not package.json!) and/or yarn.lock in your project folder.
      2. Delete node_modules in your project folder.
      3. Remove “webpack” from dependencies and/or devDependencies in the package.json file in your project folder.
      4. Run npm install or yarn, depending on the package manager you use.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Back To Top