Cov txheej txheem:
Video: Yuav Ua Li Cas Siv Node.js App ntawm Heroku: 3 Cov Kauj Ruam
2024 Tus sau: John Day | [email protected]. Kawg hloov kho: 2024-01-30 09:24
Nov yog qhov kuv tau siv kuv li NodeJS App ntawm Heroku siv tus as khauj dawb. Tsuas yog nyem qhov txuas mus rub cov software tsim nyog:
Software siv:
VSCode (lossis cov ntawv sau uas koj xaiv)
HerokuCLI
Git
Kauj ruam 1: Tsim Package.json
Taw qhia:
Heroku yog ahosting lub vev xaib uas tso cai rau ypu xa 5 daim ntawv thov pub dawb nrog lub sijhawm ua haujlwm ntawm 500+ teev hauv ib hlis. Txhawm rau xa ib qho, koj yuav tsum xa 3 cov ntaub ntawv:
Ib pob.json thiab pob-lock.json flle. Koj tuaj yeem ua raws kuv lwm qhov kev qhia rau ib qib los ntawm kauj ruam turtorial ntawm kev ua ib qho los ntawm txhaj ntawm no. Pob-lock.json qhia tau pom tom qab lub pob.json tau ua. Txij li thaum peb yuav tau khiav nws ntawm herku, ntawm koj pob, json cov ntaub ntawv koj xav tau kom paub meej qhov pib sau ntawv thiab qhov tseeb ntawm koj cov node ntawm enines. rau tam sim no qhov no khiav cov lus txib ntawm -v. Nov yog qhov piv txwv:
{
"npe": "heroku", "version": "1.0.0", Cov.
"lus piav qhia": "", "lub ntsiab": "index.js", "cov ntawv": {
"test": "ncha \" Yuam kev: tsis muaj qhov ntsuas tshwj xeeb / "&& tawm 1", "pib": "node server.js"
}, "cov ntsiab lus": , "tus sau": "", "daim ntawv tso cai": "ISC", "xyaw": {
"node": "12.x"
}
}
Kauj ruam 2: Tsim Koj Node.js App
Txij li cov app no yuav khiav ntawm txhua qhov chaw nres nkoj heroku muab rau peb, peb yuav tsum txiav txim siab tus lej nws yuav muab rau peb los ntawm kev siv cov cai no.env. PORT. Nov yog lub node js app uas hais tias "nyob zoo":
const http = xav tau ('http'); // thauj cov tsev qiv ntawv los pab nws ua tus servervar chaw nres nkoj = process.env. PORT || 5000; // qhia meej qhov chaw nres nkoj tsis hais dab tsi heroku muab lossis 5000 ntawm tus tswv hauv zos http.createServer (muaj nuj nqi (req, res) {// tsim server server res.writeHead (200, {'Cov ntsiab lus-hom': 'ntawv/dawb')); // Qhia meej tias cov lus teb "nyob zoo" yog cov ntawv res.end ("nyob zoo"); // qhia cov ntawv "nyob zoo" ntawm nplooj ntawv eweb}). Mloog (chaw nres nkoj); // txuas tus neeg rau zaub mov no mus rau chaw nres nkoj tsis.
Kauj ruam 3: Command Prompt
- Qhib koj cov lus txib tam sim los ntawm nias Windows+R qhib "Khiav" lub thawv tom qab ntawd ntaus "cmd" thiab tom qab ntawv nyem "OK"
- Ntawm koj CMD, mus rau hauv paus los ntawm kev ntaus "cd.." kom txog thaum tsis muaj txoj hauv kev suav nrog.
- Txheeb xyuas yog tias npm (tus thawj tswj tsev qiv ntawv teeb tsa los ntawm node), git thiab heroku raug teeb tsa kom raug los ntawm kev ntaus:
npm -rov
git --version heroku --version
Nkag mus rau hauv koj tus account herku
heroku tus ID nkag mus
Qhov no tsim ib qho app ntawm heroku:
heroku tsim
Txhawm rau upload koj cov ntaub ntawv, koj yuav tsum tau mus rau nws txoj hauv kev los ntawm kev ntaus cd
ua cd
Tsim qhov chaw cia khoom tshiab (nplaub tshev) ntawm koj lub cuab yeej hauv zos rau cov khoom hauv txoj kev no
git pib
Txuas nyob deb mus rau daim nplaub tshev ntawm heroku ntawm git ntawm koj li app
heroku git: tej thaj chaw deb
Luam theej tawm cov ntawv no nyob deb rau koj lub zos git repository u ntawm git ntawm koj li app
git ua add.
Txuag qhov kev hloov pauv uas koj tau ua ntawm daim nplaub tshev nrog cov lus ntawm "ua kom nws zoo dua"
git cog lus -am "ua kom nws zoo dua"
Rub tawm cov ntawv mus rau git nplaub tshev ntawm heroku. Tos nws downlaod
git thawb heroku master
qhib lub app
heroku qhib app
Pom zoo:
YUAV UA LI CAS YUAV UA LI CAS YUAV TSUM MUAJ KEV LAG LUAM CIRCUIT Siv D882 Tus Neeg Soj Ntsuam: 3 Kauj Ruam
YUAV UA LI CAS YUAV UA LI CAS YUAV TSUM TAU LWM YAM CIRCUIT Siv D882 Tus Kws Tshaj Lij: HELLO phooj ywg, Zoo siab txais tos rau kuv CHANNEL, Hnub no kuv yuav qhia koj li cas kom ua tau CIRCUIT ntawm kev siv hluav taws xob tsis siv neeg lub teeb pom kev siv D882
Yuav Ntsuas Li Cas Ntsuas Kev Siv Lub Hwj Chim ntawm Kev Sib Txuas Lus Wireless hauv Era ntawm Kev Siv Hluav Taws Xob?: 6 Cov Kauj Ruam
Yuav Ua Li Cas Ntsuas Kom Tau Txais Kev Siv Lub Hwj Huam ntawm Kev Sib Txuas Lus Wireless hauv Era ntawm Kev Siv Hluav Taws Xob? Feem ntau IoT nodes yuav tsum tau siv lub roj teeb. Tsuas yog los ntawm kev ntsuas ntsuas lub zog siv ntawm lub wireless wireless peb tuaj yeem kwv yees kwv yees ntau npaum li cas roj teeb kuv
Yuav Ua Li Cas Kho Lub Rooj Tog Zaum Lub Hwj Huam Muab Tawm Tawm ntawm Cov Pc Cov Khoom Siv Hluav Taws Xob: 6 Cov Kauj Ruam (nrog Duab)
Yuav Ua Li Cas Hloov Kho Lub Rooj Tog Zaum Lub Hwj Huam Tawm ntawm Cov Pc Cov Khoom Siv Hluav Taws Xob qub: Kuv muaj lub PC qub Lub Hwj Huam Muab tso nyob ib puag ncig.Yog li kuv tau txiav txim siab los ua lub rooj zaum kho kom raug lub zog tawm ntawm nws.Peb xav tau ntau qhov sib txawv ntawm qhov hluav taws xob rau lub zog lossis txheeb xyuas cov hluav taws xob sib txawv lossis cov phiaj xwm. Yog li nws ib txwm zoo kom muaj kev kho tau
Yuav Ua Li Cas Tau Txais Cov Nkauj Los Ntawm Txhua Qhov (Haha) Lub Vev Xaib (Ntev Li Koj Tau hnov Nws Koj Yuav Tau Txais Nws Ok Zoo Yog Nws Tau Ntxig Hauv Flash Koj Yuav Tsis Muaj Peev Xwm) EDITED !!!!! Ntxiv Info: 4 Cov Kauj Ruam
Yuav Ua Li Cas Tau Txais Cov Nkauj Los Ntawm Txhua Qhov (Haha) Lub Vev Xaib (Ntev Li Koj Tau hnov Nws Koj Yuav Tau Txais Nws … Ok Zoo Yog Nws Tau Ntxig Hauv Flash Koj Yuav Tsis Muaj Peev Xwm) EDITED !!!!! Ntxiv Cov Lus Qhia: yog tias koj tau mus rau lub vev xaib thiab nws ua nkauj nkauj uas koj nyiam thiab xav tau nws ntawm no yog cov lus qhia rau koj tsis yog kuv qhov txhaum yog tias koj cuam tshuam qee yam (tsuas yog txoj hauv kev nws yuav tshwm sim yog tias koj pib tshem cov khoom yam tsis muaj laj thawj. ) Kuv tuaj yeem tau txais cov nkauj rau
Yuav Ua Li Cas Ntxiv Cov Neeg Siv Los Ntawm NUMA rau Koj Luam Ntawm N Siv NumADD Firefox Ntxiv Rau: 4 Cov Kauj Ruam
Yuav Ua Li Cas Ntxiv Cov Neeg Siv Los Ntawm NUMA rau Koj Luam Ntawm N Siv NumADD Firefox Ntxiv Ntxiv: Txhua tus siv ntawm Metanet's N tus neeg siv qib database NUMA yuav paub tias qhov cuam tshuam ntawm qhov cuam tshuam yog rau theej tus neeg siv tsim qib rau koj daim ntawv theej ntawm game. NumADD, tshem tawm qhov xav tau rau kev theej thiab muab tshuaj txhuam thiab ua kom hloov pauv qib ua haujlwm ntawm ib tus nas