Express js: The Ultimate Beginner's Guide to Learn Express js Step by Step 2020 (2st Edition)
Download 316.23 Kb. Pdf ko'rish
|
Express JS
Install Node.js
To obtain the latest version of Node.js: If you are using Windows or Mac, head to the Node.js homepage. The site will identify your system and its structure and select the appropriate installer, just click on the Install button to download the installer and then open it and continue with the steps.node-home-page-windows.thumb. jpg.41c2139 node-install-windows-1.thumb.jpg.5aeff31 node-install-windows-7.thumb.jpg.d2c7edf node-install-windows-8.thumb.jpg.bcb6f2c If you're using Arch Linux, you'll find the latest version of Node.js under Arch User Repositories (AUR). It can be installed with the following command if you are using yaourt (similar for all programs that provide access to AUR): yaourt -S nodejs --noconfirm You will be asked to enter the password to your user or the password to the root user (if any). It can also be installed as described in the following option. If you are using another Linux distribution, you may find an outdated version of Node.js in your distribution repositories, so we recommend that you install Node.js through the Node.js version manager available on GitHub, and install in the following way: Download the latest version of Node.js version manager via the Download ZIP button on the project page on GitHub. Unzip the downloaded file Move the terminal to the volume path of the previous operation, for example: cd ~ / Downloads / n-master Then execute the build order: sudo make install Install the latest stable version of Node.js using the n command provided by Node.js Version Manager: sudo n stable You will be prompted to enter your user password or the root user password, if any. One of the benefits of the Node.js version manager is that you can quickly switch between several versions of Node.js, sometimes you might want to try out some of the features available in an unstable version (such as v0.11 that includes some ECMAScript 6 components) using the n latest command, but you want Return to work on serious projects within a stable version. So you can use the n stable command. Build the project To start working cleanly, create a new folder somewhere in your device and navigate to it using the terminal. Linux, Mac, and Windows): cd / home / f / my-blog In Windows, it might be similar to this: cd C: \ Users \ f \ my-blog We will use the init command provided by the Node Package Manager (npm) to create a new project, open the terminal (Windows command line) and type the following command: npm init The program will offer you a set of fields to fill in: Name: The name of the project, npm suggests the name of the current folder as the name of the project, and you can suggest that you leave the field blank and press Enter. Version: Project version (you can leave it as is). Description: Description of the project. Entry point: The main file from which the project starts, you can leave it as is and create the index.js file later. Test command: The command that npm should execute when it is asked to perform tests on the project, ie when the npm test command is executed within the main project folder. We'll leave it blank now. Git repository: The git repository path that you will use to manage the project, can be a http: // or git: // link and can be modified later. Keywords: project keywords separated by a comma (,), examples: blog, mysql, expressjs, tutorial. Author: Project writer. License: Project license, any license such as GPLv2 or MIT can be used. When finished, the program will show you the information you have entered and ready to write to the package.json file, type yes to write the file. The package.json file is the starting point for all Node.js projects, and is used to identify and describe the project when it is published in the npm package log. Clone the project and re-install the requirements for modification at another time or by other persons. Install the project requirements Our project will rely on the Express framework as evident, in addition to MySQL databases for storing blogs and users and their comments, we will also need some other requirements that we will install when we need them. To install the latest version of express and save it as a requirement within the package.json file, run the following command: npm install express --save Note: We will use version 4 in this series as the most recent version at the time of writing. To make sure that version 4 is installed even after newer versions are released, you can use the command: npm install express@4.10.* --save The installation of MySQL takes two steps: First, install the server that provides the database, and performs differently for each operating system: In Windows and Mac OS X, it can be installed by downloading the appropriate installation software for the system version and architecture from the official site and then following the installation steps as in installing any other software. In Arch Linux, I recommend using MariaDB, a completely identical alternative to MySQL and replacing it without having to modify any part of the code, and can be installed through Arch users' repositories with the following command: yaourt -S mariadb --noconfirm In other Linux distributions such as Ubuntu and Fedora, MariaDB and MySQL may be available in official repositories and can be installed using apt-get and yum. The other step involves installing the MySQL client (or MySQL client), the Download 316.23 Kb. Do'stlaringiz bilan baham: |
Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling
ma'muriyatiga murojaat qiling