Next step of creating Node.js application is installing additional frameworks and dependencies that facilitate work with the project.
In our lesson we will use popular web framework “Express” and utility “Nodemon”, that will monitor for any changes in your source and automatically restart your server.
To install this dependencies in console write commands:
npm install express
npm install -D nodemon
Flag -D means that this is developer dependency and it not used in production project.
In section “scripts” write create script “start” and “dev”:
Never send your passwords and restricted data openly to other people!All social networks and messengers always save your data on servers and some third persons possibly can read your messages.
If you need to send secret data – send encrypted link that can only be viewed once. Don’t write from which service is this password, tell it to other person by phone or in other messenger.
In this case, the connection between the service and the password is broken and no one will be able to get the password, except to whom you sent the message.
This service with open source and MIT license encrypt your message and generate special URL link, that you can send in social network or messenger to other people, after reading your message it will be automatically destroyed and no one will be able to read your message again.
Another PHP framework for web applications is Symfony. It is used by thousands of web applications (including BlaBlaCar.com and Spotify.com) and most of the popular PHP projects (including Drupal and Magento).GitHub Stars: 17.8k+
Next lets create new folder “react-app” with files of our application. In this folder create two empty files: index.html, package.json, and subfolder src such as on screenshot:
File index.html will have basic html markup:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>React App</title>
</head>
<body>
<noscript>
You need to enable JavaScript to run this app.
</noscript>
<div id="root"></div>
<!-- Bundle -->
<script src="./src/index.js"></script>
</body>
</html>
In subfolder src create file index.js, it will be main file of our react application:
NodeSource – це компанія, орієнтована на забезпечення підтримки Node корпоративного рівня, і вони підтримують сховище, що містить останні версії Node.js.
Щоб встановити Node.js і npm з сховища NodeSource, виконайте такі дії:
1. Увімкніть сховище NodeSource наступною командою curl:
Наведена вище команда додасть ключ підпису NodeSource до вашої системи, створить файл сховища apt source, встановить всі необхідні пакети та оновить кеш apt.
Поточна версія LTS Node.js є версією 10.x, Carbon. Якщо вам потрібно встановити версію 8.x, просто замініть setup_10.x на setup_8.x
2. Після додавання репозиторію NodeSource встановіть Node.js і npm, командою:
sudo apt install nodejs
3. Переконайтеся, що Node.js та npm успішно встановлені, надрукувавши їх версії