Modern Full-Stack Development


Initializing a New NPM/Node Project



Download 5,64 Mb.
Pdf ko'rish
bet13/107
Sana06.08.2021
Hajmi5,64 Mb.
#140576
1   ...   9   10   11   12   13   14   15   16   ...   107
Bog'liq
Modern Full-Stack Development Using TypeScript, React, Node

 Initializing a New NPM/Node Project
Now, in all of this, I did skip one step that clearly is optional but is, in fact, typical, and 
that’s initializing a new project. With most Node/NPM projects, you’ll also have a file 
named package.json in the root directory of the project. This file is the project manifest 
file, and it provides metadata information to NPM (and Node, at least indirectly) about 
your project that it needs to do certain things. It will tell NPM what modules to install if 
they haven’t been installed yet for one thing (which makes giving a project to another 
developer very easy!). It will also contain information like the name and version of the 
project, its main entry point, and lots of other information (most of which is optional, but 
we’ll look at that a bit more in the next chapter).
While you can write this file by hand or even go entirely without it, it’s a good idea to 
have it, and it’s a good idea to let NPM create it for you, which you can do by executing 
this command:
npm init
If you are following along, please make sure the directory you run this from is empty 
(delete node_modules and package-lock.json if present, both of which will be described 
later). This will trigger an interactive process that walks you through the creation of the 
package.json file, something like you see in Figure 
1-4
.
Chapter 1   Server-Side aCtion: node and npM


12
This will walk you through an interactive, step-by-step process wherein you can 
enter whichever information is relevant to your project, if any. You can just hit Enter on 
each option to use the default (or a blank value, whichever is applicable), or you can 
enter the values that are appropriate to you. For our purposes here though, you indeed 
can and should simply hit Enter on each prompt in the process.
Figure 1-4.  Initializing a project with NPM
Chapter 1   Server-Side aCtion: node and npM


13
Opening the generated package.json file should look something like this:
{
  "name": "temp",
  "version": "1.0.0",
  "description": "Init'ing a project",
  "main": "test.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "Frank W. Zammetti",
  "license": "ISC"
}

Download 5,64 Mb.

Do'stlaringiz bilan baham:
1   ...   9   10   11   12   13   14   15   16   ...   107




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish