ReactJS — это библиотека Javascript, используемая для быстрого создания интерактивных пользовательских интерфейсов. На момент написания статьи это самая популярная библиотека JavaScript для разработки. React превосходит своих конкурентов таких как Angular и Vue JS по функциональности и популярности.
ReactJS был разработан компанией Facebook в 2011 году и очень быстро обрел свою популярность из-за его гибкости и простоты. Что и сделало React востребованным при разработке мобильных и веб-приложений. Его использую такие гиганты как Facebook , Instagram , Netflix , Airbnb и Twitter. Так же используют React и более 90 000 сайтов в сети интернет.
В этой статье вы узнаете, как установить ReactJS на Ubuntu 20.04 и Ubuntu 18.04.
Шаг 1: Установка NPM в Ubuntu
Создайте приложение React, создайте свое первое приложение с React Ubuntu 20.04
C++ первая программа HELLO WORLD в Linux Ubuntu
В следующей статье мы рассмотрим как мы можем создать наше первое приложение с ReactJS в Ubuntu 20.04, используя Create React App. ReactJS — это библиотека JavaScript с открытым исходным кодом, используемая для создания пользовательского интерфейса, поддерживаемая Facebook и сообществом разработчиков. ReactJS можно использовать при разработке веб-приложений или мобильных приложений.
В React, также известен как ReactJS, данные обрабатываются в DOM. Для запуска приложения React требуются дополнительные библиотеки для маршрутизации и управления состоянием. Некоторые примеры этих библиотек: Redux y Реактивный маршрутизатор.
- 1 Установка React в Ubuntu 20.04
- 1.1 Установить npm
- 1.2 Установите приложение create-response-app
- 2.1 Запуск приложения React
Установка React в Ubuntu 20.04
Чтобы установить React в нашей системе, мы должны сначала узнать, что такое npm, и понять, зачем они нам нужны. Npm — это аббревиатура от Node Package Manager., и это крупнейший в мире реестр программного обеспечения с открытым исходным кодом. Содержит более 800.000 XNUMX кодовых пакетов. Npm можно использовать бесплатно, и любое общедоступное программное обеспечение можно загрузить и использовать без регистрации или входа в систему.
Npm — это инструмент управления зависимостями для приложений javascript, который помогает установить все библиотеки и другие инструменты для поддержки разработки JS-приложений.
Установить npm
к установить nodejs, который включает npm, нам останется только открыть терминал (Ctrl + Alt + T) и выполнить следующую команду:
sudo apt install nodejs
После завершения установки npm мы можем проверьте свою версию и версию узла. Сделать это можно с помощью команды:
npm -v
Установленная версия npm зависит от даты установки, так как обновление выполняется часто. Необходимо, чтобы мы убедились, что у нас установлена версия выше 5.
Установка программ в Ubuntu
к проверить установленную версию узла, используемая команда будет следующей:
node -v
Если в вашей системе не установлена последняя версия npm, вы можете обновить Node Package Manager (npm) до последней версии запуск этой команды в терминале:
Установите приложение create-response-app
Чтобы установить продуктивную среду React, нам нужно будет настроить такие инструменты, как babel, webpack и т. Д., Которые сложно настроить для новичков в мире React. Но мы можем найти несколько инструментов, которые помогут нам в настройке. Среди них мы найдем create-react-app — самый простой инструмент в использовании и настройке..
Create React App — удобная среда для изучения React, и это лучший способ начать создание нового одностраничного приложения с помощью React.
Create React App настройте вашу среду разработки так что вы можете использовать новейшие функции Javascript, обеспечивая хороший опыт разработки и оптимизируя ваше приложение для производства. Как указано на их веб-сайте, на вашем компьютере должны быть установлены Node> = 8.10 и npm> = 5.6.
Compiling things on Ubuntu the Easy Way
Let’s say you are a moderately experienced Linux user, and you want to install an application off the Internet but it doesn’t have a nice package that works on your system. (If it does have a package, install it following the instructions on InstallingSoftware.)
A lot of users, even quite experienced ones, have issues with going from the tarball to the installed program because they just do not know the fairly easy steps required to get the job done. But it’s only easy if you already know how to do it! So, here’s a quick guide about how to install stuff from developer sites.
Step 1: Prep your system for building packages
By default, Ubuntu does not come with the tools required. You need to install the package build-essential for making the package and checkinstall for putting it into your package manager. These can be found on the install CD or in the repositories, searching in Synaptic Package Manager or the command-line apt-get:
sudo apt-get install build-essential checkinstall
And since you may want to get code from some projects with no released version, you should install appropriate version management software.
sudo apt-get install cvs subversion git-core mercurial
You should then build a common directory for yourself where you’ll be building these packages. We recommend creating /usr/local/src, but really you can put it anywhere you want. Make sure this directory is writable by your primary user account, by running
sudo chown $USER /usr/local/src
and, just to be safe
sudo chmod u+rwx /usr/local/src
After you’ve done this, you’re set up to start getting the programs you need.
Step 2: Getting the software you want
Most of the software you’ll generally want comes from released tarballs. These are just compressed archives with extensions like .tar.gz or .tar.bz2 — they are just like .zip files on Windows or .sit on MacOS X, if that analogy helps you. If the program you want to install comes in this form, you should move it into the /usr/local/src directory we made in Step 1 and extract it by right-clicking on the file and selecting Extract Here, or by using the command line: If your tarball is a .gz, extract the files with the command:
tar -xzvf tarballname.tar.gz
and for bz2 the similar command:
tar -xjvf tarballname.tar.bz2
In the rare case of getting a program from a cvs or subversion repository, the developers will generally provide instructions on how to do this on their website. If you already installed the packages listed on Step 1, you just need to change to your /usr/local/src directory (cd /usr/local/src) and run the commands that are listed. The procedure will vary from program to program, so I can’t help you here, but with the given packages the instructions they provide should work smoothly.
Note: If you downloaded from source such as Git, SVN, or any other source repository then it is likely that the ./configure files have not yet been generated. You may be able to run the command
autogen.sh
from within the downloaded files top directory. This command relies on automake and autoconf programs and will automatically build the configuration files and run the ./configure command. After this step you can resume the later directions by running the command
make
Step 3: Resolving Dependencies.
- You probably want to read about the possibilities and limitations of auto-apt first, which will attempt to take care of dependency issues automatically. The following instructions are for fulfilling dependencies manually:
To prepare, install the package apt-file, and then run sudo apt-file update. This will download a list of all the available packages and all of the files those packages contain, which as you might expect can be a very large list. It will not provide any feedback while it loads, so just wait.
The apt-file program has some interesting functions, the two most useful are apt-file search which searches for a particular file name, and apt-file list which lists all the files in a given package. (Two explanations: 1 2)
- If you run ./configure without any options, you will use the default settings for the program. Most programs have a range of settings that you can enable or disable, if you are interested in this check the README and INSTALL files found in the directory after decompressing the tar file. You can check the developer documentation and in many cases ./configure —help will list some of the key configurations you can do. A very common options is to use ./configure —prefix=/usr which will install your application into /usr instead of /usr/local as my instructions do.
If this happens, the last line of output will be something like
configure: error: Library requirements (gobbletygook) not met, blah blah blah stuff we don’t care about
But right above that it will list a filename that it cannot find (often a filename ending in «.pc», for instance). What you need to do then is to run
apt-file search missingfilename.pc
which will tell you which Ubuntu package the missing file is in. You can then simply install the package using
sudo apt-get install requiredpackage
Then try running ./configure again, and see if it works. If you get to a bunch of text that finishes with config.status: creating Makefile followed by no obvious error messages, you’re ready for the next steps.
Step 4: Build and install.
If you got this far, you’ve done the hardest part already. Now all you need to do is run the command
make
which does the actual building (compiling) of the program.
- If it’s a large program or if you’ve got a very slow computer, go and get a cup of coffee or something. If you have a multi-core processor you can also set the variable CONCURRENCY_LEVEL to the number of processors/cores you have to speed things up a little.
When its done, install the program. You probably want to use
sudo checkinstall
which puts the program in the package manager for clean, easy removal later. This replaces the old sudo make install command. See the complete documentation at CheckInstall.
Note: If checkinstall fails you may need to run the command like
sudo checkinstall —fstrans=0
Which should allow the install to complete successfully. Bugs: 78455 easier than tearing your hair out and then screaming about how much Linux sucks while running around the room». Not actually easy.
Attachments
The process described in this page can be performed without typing terminal commands, using the attached application. Download the package kludge_tarball_installer_v0.10.tar, extract it to your user folder, and see the README file.
Links
- The «easy» tutorial should be the default one (at CompilingSoftware), and the «advanced» tutorial should be at a name like CompilingSoftwareAdvanced. The target audience for a document like this is people who have never done any of this stuff before. Make the default document as easy to use as possible.
- Would it be better to change the group of /usr/local/src/ to admin and give them rwx privleages? Since anyone adding and removing software should be in the admin group.
*Would be nice to see an example tar ball included in the post. Would make it easy for someone to test the steps.
CompilingEasyHowTo (последним исправлял пользователь knome 2013-12-13 21:04:47)
The material on this wiki is available under a free license, see Copyright / License for details
You can contribute to this wiki, see Wiki Guide for details
Источник: help.ubuntu.com