{"id":93917,"date":"2025-12-30T15:10:09","date_gmt":"2025-12-30T08:10:09","guid":{"rendered":"https:\/\/itviec.com\/blog\/?p=93917"},"modified":"2025-12-30T15:10:11","modified_gmt":"2025-12-30T08:10:11","slug":"huong-dan-npm-init","status":"publish","type":"post","link":"https:\/\/itviec.com\/blog\/huong-dan-npm-init\/","title":{"rendered":"NPM init: H\u01b0\u1edbng d\u1eabn c\u00e1ch d\u00f9ng l\u1ec7nh kh\u1edfi t\u1ea1o d\u1ef1 \u00e1n Node.js"},"content":{"rendered":"<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_85 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">N\u1ed9i dung b\u00e0i vi\u1ebft<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/itviec.com\/blog\/huong-dan-npm-init\/#Lenh_npm_init_duoc_dung_de_lam_gi\" >L\u1ec7nh npm init \u0111\u01b0\u1ee3c d\u00f9ng \u0111\u1ec3 l\u00e0m g\u00ec?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/itviec.com\/blog\/huong-dan-npm-init\/#Lenh_npm_init_%E2%80%93scopeorgname_la_gi\" >L\u1ec7nh npm init &#8211;scope=@orgname l\u00e0 g\u00ec?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/itviec.com\/blog\/huong-dan-npm-init\/#Vi_du_thuc_te_ve_npm_init\" >V\u00ed d\u1ee5 th\u1ef1c t\u1ebf v\u1ec1 npm init<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/itviec.com\/blog\/huong-dan-npm-init\/#Tao_workspace_moi_trong_du_an_bang_npm_init_-w\" >T\u1ea1o workspace m\u1edbi trong d\u1ef1 \u00e1n b\u1eb1ng npm init -w<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/itviec.com\/blog\/huong-dan-npm-init\/#Thuc_hanh_khoi_tao_mot_du_an_Nodejsvoi_npm_init\" >Th\u1ef1c h\u00e0nh kh\u1edfi t\u1ea1o m\u1ed9t d\u1ef1 \u00e1n Node.jsv\u1edbi npm init<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/itviec.com\/blog\/huong-dan-npm-init\/#Thiet_lap_tuy_chon_cau_hinh_cho_lenh_npm_init\" >Thi\u1ebft l\u1eadp t\u00f9y ch\u1ecdn c\u1ea5u h\u00ecnh cho l\u1ec7nh npm init<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/itviec.com\/blog\/huong-dan-npm-init\/#Cac_cau_hoi_thuong_gap_ve_npm_init\" >C\u00e1c c\u00e2u h\u1ecfi th\u01b0\u1eddng g\u1eb7p v\u1ec1 npm init<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/itviec.com\/blog\/huong-dan-npm-init\/#Tong_ket\" >T\u1ed5ng k\u1ebft<\/a><\/li><\/ul><\/nav><\/div>\n\n<p><strong><em>npm init l\u00e0 l\u1ec7nh c\u01a1 b\u1ea3n nh\u01b0ng c\u1ef1c k\u1ef3 quan tr\u1ecdng trong quy tr\u00ecnh kh\u1edfi t\u1ea1o m\u1ed9t d\u1ef1 \u00e1n Node.js. L\u1ec7nh n\u00e0y gi\u00fap l\u1eadp tr\u00ecnh vi\u00ean t\u1ea1o t\u1ec7p package.json, n\u01a1i l\u01b0u tr\u1eef th\u00f4ng tin v\u1ec1 t\u00ean, phi\u00ean b\u1ea3n, dependencies v\u00e0 script. Khi ch\u1ea1y npm init, ng\u01b0\u1eddi d\u00f9ng s\u1ebd \u0111\u01b0\u1ee3c h\u01b0\u1edbng d\u1eabn qua t\u1eebng b\u01b0\u1edbc nh\u1eadp th\u00f4ng tin c\u01a1 b\u1ea3n, t\u1eeb \u0111\u00f3 x\u00e2y d\u1ef1ng n\u1ec1n t\u1ea3ng v\u1eefng ch\u1eafc cho qu\u00e1 tr\u00ecnh ph\u00e1t tri\u1ec3n.<\/em><\/strong><\/p>\n\n\n\n<p>\u0110\u1ecdc b\u00e0i vi\u1ebft sau \u0111\u1ec3 \u0111\u01b0\u1ee3c gi\u1ea3i \u0111\u00e1p chi ti\u1ebft h\u01a1n v\u1ec1:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>npm init l\u00e0 g\u00ec v\u00e0 ho\u1ea1t \u0111\u1ed9ng th\u1ebf n\u00e0o<\/li>\n\n\n\n<li>C\u00fa ph\u00e1p l\u1ec7nh v\u00e0 c\u00e1c tu\u1ef3 ch\u1ecdn ph\u1ed5 bi\u1ebfn<\/li>\n\n\n\n<li>S\u1ef1 kh\u00e1c bi\u1ec7t gi\u1eefa <code>npm init<\/code>, <code>npm init -y<\/code>, <code>npm init --scope=@orgname<\/code><\/li>\n\n\n\n<li>C\u00e1ch t\u1ea1o workspace v\u1edbi <code>npm init -w<\/code><\/li>\n\n\n\n<li>H\u01b0\u1edbng d\u1eabn kh\u1edfi t\u1ea1o m\u1ed9t d\u1ef1 \u00e1n v\u1edbi npm init<\/li>\n\n\n\n<li>C\u00e1ch thi\u1ebft l\u1eadp c\u1ea5u h\u00ecnh t\u00f9y ch\u1ecdn cho l\u1ec7nh npm init<\/li>\n<\/ul>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p><em>\u0110\u1ecdc chi ti\u1ebft: <strong><a href=\"https:\/\/itviec.com\/blog\/npm-la-gi\/\" target=\"_blank\" rel=\"noreferrer noopener\">NPM l\u00e0 g\u00ec: Kh\u00e1i ni\u1ec7m, l\u1ec7nh v\u00e0 thao t\u00e1c c\u01a1 b\u1ea3n v\u1edbi NPM<\/a><\/strong><\/em><\/p>\n<\/blockquote>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-l\u1ec7nh-npm-init-d\u01b0\u1ee3c-dung-d\u1ec3-lam-gi\"><span class=\"ez-toc-section\" id=\"Lenh_npm_init_duoc_dung_de_lam_gi\"><\/span><strong>L\u1ec7nh npm init \u0111\u01b0\u1ee3c d\u00f9ng \u0111\u1ec3 l\u00e0m g\u00ec?<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>L\u1ec7nh <code><strong>npm init &lt;initializer><\/strong><\/code> \u0111\u01b0\u1ee3c s\u1eed d\u1ee5ng \u0111\u1ec3 thi\u1ebft l\u1eadp m\u1ed9t g\u00f3i npm m\u1edbi ho\u1eb7c c\u1eadp nh\u1eadt m\u1ed9t g\u00f3i npm hi\u1ec7n c\u00f3.<\/p>\n\n\n\n<p>C\u1ee5 th\u1ec3, initializer l\u00e0 m\u1ed9t g\u00f3i npm c\u00f3 t\u00ean d\u1ea1ng <code>create-&lt;initializer><\/code>. Khi b\u1ea1n ch\u1ea1y <code>npm init<\/code>, npm s\u1ebd t\u1ef1 \u0111\u1ed9ng g\u1ecdi <strong>npm exec<\/strong> \u0111\u1ec3 c\u00e0i \u0111\u1eb7t r\u1ed3i th\u1ef1c thi t\u1eadp tin ch\u00ednh (main bin) c\u1ee7a n\u00f3. Th\u00f4ng th\u01b0\u1eddng l\u1ec7nh n\u00e0y th\u01b0\u1eddng \u0111\u01b0\u1ee3c d\u00f9ng \u0111\u1ec3:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>T\u1ea1o ho\u1eb7c c\u1eadp nh\u1eadt t\u1ec7p package.json<\/li>\n\n\n\n<li>Th\u1ef1c hi\u1ec7n c\u00e1c b\u01b0\u1edbc kh\u1edfi t\u1ea1o kh\u00e1c (v\u00ed d\u1ee5: t\u1ea1o th\u01b0 m\u1ee5c, script m\u1eabu, ho\u1eb7c c\u1ea5u h\u00ecnh build)<\/li>\n<\/ul>\n\n\n\n<p>V\u00ed d\u1ee5, npm s\u1ebd d\u1ecbch t\u1ef1 \u0111\u1ed9ng c\u00e1c l\u1ec7nh sau:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>npm init foo&nbsp; &nbsp; &nbsp; &nbsp; -&gt;&nbsp; npm exec create-foo<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>npm init @usr\/foo &nbsp; -&gt;&nbsp; npm exec @usr\/create-foo<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>npm init @usr &nbsp; &nbsp; &nbsp; -&gt;&nbsp; npm exec @usr\/create<\/code><\/pre>\n\n\n\n<p>N\u1ebfu b\u1ea1n kh\u00f4ng ch\u1ec9 \u0111\u1ecbnh initializer (t\u1ee9c l\u00e0 ch\u1ec9 g\u00f5 npm init), npm s\u1ebd quay l\u1ea1i h\u00e0nh vi kh\u1edfi t\u1ea1o m\u1eb7c \u0111\u1ecbnh (legacy init). Khi \u0111\u00f3, n\u00f3 s\u1ebd hi\u1ec3n th\u1ecb h\u00e0ng lo\u1ea1t c\u00e2u h\u1ecfi v\u00e0 t\u1ea1o t\u1ec7p package.json cho b\u1ea1n.<\/p>\n\n\n\n<p>Trong qu\u00e1 tr\u00ecnh n\u00e0y, npm s\u1ebd c\u1ed1 g\u1eafng t\u1ef1 \u0111\u1ed9ng \u0111i\u1ec1n c\u00e1c gi\u00e1 tr\u1ecb h\u1ee3p l\u00fd d\u1ef1a tr\u00ean nh\u1eefng tr\u01b0\u1eddng, dependencies ho\u1eb7c t\u00f9y ch\u1ecdn \u0111\u00e3 c\u00f3 s\u1eb5n. Qu\u00e1 tr\u00ecnh n\u00e0y mang t\u00ednh b\u1ed5 sung (additive), ngh\u0129a l\u00e0 npm s\u1ebd gi\u1eef nguy\u00ean m\u1ecdi gi\u00e1 tr\u1ecb v\u00e0 tr\u01b0\u1eddng \u0111\u00e3 \u0111\u01b0\u1ee3c thi\u1ebft l\u1eadp tr\u01b0\u1edbc \u0111\u00f3.<\/p>\n\n\n\n<p>B\u1ea1n c\u0169ng c\u00f3 th\u1ec3 s\u1eed d\u1ee5ng t\u00f9y ch\u1ecdn <code>-y<\/code> ho\u1eb7c <code>--yes<\/code> \u0111\u1ec3 b\u1ecf qua to\u00e0n b\u1ed9 b\u01b0\u1edbc tr\u1ea3 l\u1eddi c\u00e2u h\u1ecfi v\u00e0 kh\u1edfi t\u1ea1o t\u1ec7p package.json v\u1edbi c\u00e1c gi\u00e1 tr\u1ecb m\u1eb7c \u0111\u1ecbnh. Ngo\u00e0i ra, n\u1ebfu b\u1ea1n th\u00eam t\u00f9y ch\u1ecdn <code>--scope<\/code>, npm s\u1ebd t\u1ef1 \u0111\u1ed9ng t\u1ea1o m\u1ed9t g\u00f3i c\u00f3 ph\u1ea1m vi (scoped package).<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-npm-init-y-la-gi-va-khac-gi-npm-init-th\u01b0\u1eddng\"><strong>npm init -y l\u00e0 g\u00ec v\u00e0 kh\u00e1c g\u00ec npm init th\u01b0\u1eddng?<\/strong><\/h3>\n\n\n\n<p>L\u1ec7nh <code>npm init -y<\/code> \u0111\u01b0\u1ee3c s\u1eed d\u1ee5ng \u0111\u1ec3 t\u1ef1 \u0111\u1ed9ng thi\u1ebft l\u1eadp t\u1ea5t c\u1ea3 c\u00e1c c\u00e2u tr\u1ea3 l\u1eddi trong qu\u00e1 tr\u00ecnh kh\u1edfi t\u1ea1o d\u1ef1 \u00e1n b\u1eb1ng gi\u00e1 tr\u1ecb m\u1eb7c \u0111\u1ecbnh.<\/p>\n\n\n\n<p>Khi ch\u1ea1y l\u1ec7nh n\u00e0y, npm s\u1ebd t\u1ea1o ngay l\u1eadp t\u1ee9c m\u1ed9t t\u1ec7p package.json v\u1edbi c\u00e1c gi\u00e1 tr\u1ecb m\u1eb7c \u0111\u1ecbnh m\u00e0 kh\u00f4ng c\u1ea7n b\u1ea1n ph\u1ea3i tr\u1ea3 l\u1eddi b\u1ea5t k\u1ef3 c\u00e2u h\u1ecfi n\u00e0o. \u0110\u00e2y l\u00e0 c\u00e1ch kh\u1edfi t\u1ea1o nhanh ch\u00f3ng, ti\u1ec7n l\u1ee3i cho nh\u1eefng d\u1ef1 \u00e1n th\u1eed nghi\u1ec7m ho\u1eb7c khi b\u1ea1n mu\u1ed1n ti\u1ebft ki\u1ec7m th\u1eddi gian thi\u1ebft l\u1eadp ban \u0111\u1ea7u.<\/p>\n\n\n\n<p>B\u00ean c\u1ea1nh <code>npm -y<\/code> th\u00ec c\u00f2n m\u1ed9t c\u00e1ch d\u00f9ng kh\u00e1c \u0111\u1ec3 t\u1ef1 \u0111\u1ed9ng t\u1ea1o m\u1ed9t t\u1ec7p package.json v\u1edbi c\u00e1c gi\u00e1 tr\u1ecb m\u1eb7c \u0111\u1ecbnh l\u00e0 <strong><code>npm init --force<\/code><\/strong>. Tuy nhi\u00ean, \u0111\u00e2y l\u00e0 <strong>m\u1ed9t c\u00e1ch d\u00f9ng c\u0169 <\/strong>v\u00e0 thay th\u1ebf cho <code>npm init --yes<\/code> (<code>npm init -y<\/code>). Flag <code>\u2013force<\/code> kh\u00f4ng c\u00f2n \u0111\u01b0\u1ee3c ghi trong t\u00e0i li\u1ec7u ch\u00ednh th\u1ee9c c\u1ee7a npm init, nh\u01b0ng h\u00e0nh vi tr\u01b0\u1edbc \u0111\u00e2y c\u1ee7a n\u00f3 l\u00e0 b\u1ecf qua b\u1ea3ng c\u00e2u h\u1ecfi t\u01b0\u01a1ng t\u00e1c v\u00e0 ch\u1ea5p nh\u1eadn c\u00e1c c\u00e0i \u0111\u1eb7t m\u1eb7c \u0111\u1ecbnh.<\/p>\n\n\n\n<p>Th\u00f4ng th\u01b0\u1eddng, l\u1ec7nh npm init s\u1ebd ch\u1ea1y m\u1ed9t b\u1ea3ng c\u00e2u h\u1ecfi t\u01b0\u01a1ng t\u00e1c \u0111\u1ec3 thu th\u1eadp th\u00f4ng tin cho t\u1ec7p package.json c\u1ee7a d\u1ef1 \u00e1n m\u1edbi. B\u1ea3ng c\u00e2u h\u1ecfi n\u00e0y bao g\u1ed3m c\u00e1c tr\u01b0\u1eddng nh\u01b0 name, version, description, main, author, license,&#8230; L\u1ec7nh npm <code>init --yes<\/code> (<code>-y<\/code>) s\u1ebd b\u1ecf qua t\u1ea5t c\u1ea3 c\u00e1c c\u00e2u h\u1ecfi n\u00e0y v\u00e0 t\u1ea1o ngay m\u1ed9t t\u1ec7p package.json, s\u1eed d\u1ee5ng c\u00e1c gi\u00e1 tr\u1ecb m\u1eb7c \u0111\u1ecbnh d\u1ef1a tr\u00ean th\u01b0 m\u1ee5c hi\u1ec7n t\u1ea1i v\u00e0 c\u1ea5u h\u00ecnh ng\u01b0\u1eddi d\u00f9ng npm c\u1ee7a b\u1ea1n.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-l\u1ec7nh-npm-init-scope-orgname-la-gi\"><span class=\"ez-toc-section\" id=\"Lenh_npm_init_%E2%80%93scopeorgname_la_gi\"><\/span><strong>L\u1ec7nh npm init &#8211;scope=@orgname l\u00e0 g\u00ec?<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>L\u1ec7nh <code>npm init --scope=@orgname<\/code> \u0111\u01b0\u1ee3c s\u1eed d\u1ee5ng \u0111\u1ec3 kh\u1edfi t\u1ea1o m\u1ed9t g\u00f3i npm m\u1edbi trong ph\u1ea1m vi (scope) c\u1ee7a m\u1ed9t t\u1ed5 ch\u1ee9c c\u1ee5 th\u1ec3. L\u1ec7nh n\u00e0y gi\u00fap t\u1ea1o t\u1ec7p package.json cho d\u1ef1 \u00e1n m\u1edbi, \u0111\u1ed3ng th\u1eddi t\u1ef1 \u0111\u1ed9ng c\u1ea5u h\u00ecnh t\u00ean g\u00f3i \u0111\u1ec3 li\u00ean k\u1ebft v\u1edbi ph\u1ea1m vi c\u1ee7a m\u1ed9t t\u1ed5 ch\u1ee9c ho\u1eb7c ng\u01b0\u1eddi d\u00f9ng tr\u00ean npm.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>G\u00f3i theo ph\u1ea1m vi (Scoped Packages):<\/strong> npm cho ph\u00e9p t\u1ea1o c\u00e1c \u201cg\u00f3i theo ph\u1ea1m vi\u201d, t\u1ee9c l\u00e0 nh\u1eefng g\u00f3i \u0111\u01b0\u1ee3c \u0111\u1eb7t trong kh\u00f4ng gian t\u00ean (namespace) c\u1ee7a m\u1ed9t ng\u01b0\u1eddi d\u00f9ng ho\u1eb7c t\u1ed5 ch\u1ee9c c\u1ee5 th\u1ec3. C\u00e1ch n\u00e0y gi\u00fap tr\u00e1nh xung \u0111\u1ed9t t\u00ean v\u00e0 qu\u1ea3n l\u00fd c\u00e1c g\u00f3i c\u00f3 li\u00ean quan m\u1ed9t c\u00e1ch khoa h\u1ecdc h\u01a1n.<\/li>\n\n\n\n<li><strong>Ph\u1ea1m vi t\u1ed5 ch\u1ee9c (Organization Scope):<\/strong> Khi b\u1ea1n s\u1eed d\u1ee5ng &#8211;scope=@orgname, npm init s\u1ebd t\u1ef1 \u0111\u1ed9ng t\u1ea1o t\u1ec7p package.json v\u1edbi tr\u01b0\u1eddng name \u0111\u01b0\u1ee3c \u0111\u1ecbnh d\u1ea1ng s\u1eb5n theo m\u1eabu @orgname\/package-name.<\/li>\n\n\n\n<li><strong>T\u1ea1o t\u1ec7p package.json: <\/strong>T\u01b0\u01a1ng t\u1ef1 nh\u01b0 khi ch\u1ea1y l\u1ec7nh npm init th\u00f4ng th\u01b0\u1eddng, b\u1ea1n s\u1ebd \u0111\u01b0\u1ee3c h\u01b0\u1edbng d\u1eabn qua m\u1ed9t lo\u1ea1t c\u00e2u h\u1ecfi \u0111\u1ec3 thu th\u1eadp th\u00f4ng tin v\u1ec1 g\u00f3i. D\u1eef li\u1ec7u n\u00e0y sau \u0111\u00f3 \u0111\u01b0\u1ee3c d\u00f9ng \u0111\u1ec3 t\u1ea1o t\u1ec7p package.json ho\u00e0n ch\u1ec9nh..<\/li>\n\n\n\n<li><strong>Qu\u1ea3n l\u00fd kh\u00f4ng gian t\u00ean (Namespace Management):<\/strong> L\u1ec7nh n\u00e0y \u0111\u1eb7c bi\u1ec7t h\u1eefu \u00edch khi ph\u00e1t tri\u1ec3n nhi\u1ec1u g\u00f3i trong c\u00f9ng m\u1ed9t \u0111\u1ed9i ng\u0169 ho\u1eb7c t\u1ed5 ch\u1ee9c, v\u00ec n\u00f3 gi\u00fap thi\u1ebft l\u1eadp kh\u00f4ng gian t\u00ean th\u1ed1ng nh\u1ea5t cho to\u00e0n b\u1ed9 c\u00e1c g\u00f3i \u0111\u01b0\u1ee3c c\u00f4ng b\u1ed1 tr\u00ean npm registry.<\/li>\n<\/ul>\n\n\n\n<p>V\u00ed d\u1ee5, di chuy\u1ec3n \u0111\u1ebfn th\u01b0 m\u1ee5c g\u1ed1c n\u01a1i b\u1ea1n mu\u1ed1n t\u1ea1o g\u00f3i m\u1edbi v\u00e0 ch\u1ea1y l\u1ec7nh:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>npm init --scope=@myorganization<\/code><\/pre>\n\n\n\n<p>L\u00e0m theo c\u00e1c h\u01b0\u1edbng d\u1eabn tr\u00ean m\u00e0n h\u00ecnh \u0111\u1ec3 \u0111i\u1ec1n th\u00f4ng tin chi ti\u1ebft v\u1ec1 g\u00f3i c\u1ee7a b\u1ea1n. Sau khi ho\u00e0n t\u1ea5t, t\u1ec7p package.json s\u1ebd \u0111\u01b0\u1ee3c t\u1ea1o, trong \u0111\u00f3 tr\u01b0\u1eddng name ph\u1ea3n \u00e1nh ph\u1ea1m vi b\u1ea1n \u0111\u00e3 ch\u1ec9 \u0111\u1ecbnh.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>{\n\n\u00a0\u00a0\"name\": \"@myorganization\/my-new-package\",\n\n\u00a0\u00a0\"version\": \"1.0.0\",\n\n\u00a0\u00a0\"description\": \"\",\n\n\u00a0\u00a0\"main\": \"index.js\",\n\n\u00a0\u00a0\"scripts\": {\n\n\u00a0\u00a0\u00a0\u00a0\"test\": \"echo \\\"Error: no test specified\\\" &amp;&amp; exit 1\"\n\n\u00a0\u00a0},\n\n\u00a0\u00a0\"keywords\": &#91;],\n\n\u00a0\u00a0\"author\": \"\",\n\n\u00a0\u00a0\"license\": \"ISC\"\n\n}<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-vi-d\u1ee5-th\u1ef1c-t\u1ebf-v\u1ec1-npm-init\"><span class=\"ez-toc-section\" id=\"Vi_du_thuc_te_ve_npm_init\"><\/span><strong>V\u00ed d\u1ee5 th\u1ef1c t\u1ebf v\u1ec1 npm init<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>D\u01b0\u1edbi \u0111\u00e2y l\u00e0 m\u1ed9t s\u1ed1 v\u00ed d\u1ee5 ph\u1ed5 bi\u1ebfn khi kh\u1edfi t\u1ea1o d\u1ef1 \u00e1n ho\u1eb7c g\u00f3i npm m\u1edbi:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>T\u1ea1o m\u1ed9t d\u1ef1 \u00e1n React m\u1edbi b\u1eb1ng c\u00e1ch s\u1eed d\u1ee5ng create-react-app:<\/strong><\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>$ npm init react-app .\/my-react-app<\/code><\/pre>\n\n\n\n<ul start=\"2\" class=\"wp-block-list\">\n<li><strong>Ho\u1eb7c t\u1ea1o m\u1ed9t g\u00f3i m\u1edbi t\u01b0\u01a1ng th\u00edch v\u1edbi ESM (ECMAScript Module) b\u1eb1ng create-esm:<\/strong><\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>$ mkdir my-esm-lib &amp;&amp; cd my-esm-lib\n\n$ npm init esm --yes<\/code><\/pre>\n\n\n\n<ul start=\"3\" class=\"wp-block-list\">\n<li><strong>T\u1ea1o m\u1ed9t t\u1ec7p package.json theo c\u00e1ch truy\u1ec1n th\u1ed1ng (legacy init):<\/strong><\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>$ mkdir my-npm-pkg &amp;&amp; cd my-npm-pkg\n\n$ git init\n\n$ npm init<\/code><\/pre>\n\n\n\n<ul start=\"4\" class=\"wp-block-list\">\n<li><strong>Kh\u1edfi t\u1ea1o t\u1ec7p package.json m\u00e0 kh\u00f4ng c\u1ea7n tr\u1ea3 l\u1eddi b\u1ea5t k\u1ef3 c\u00e2u h\u1ecfi n\u00e0o:<\/strong><\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>$ npm init -y<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-t\u1ea1o-workspace-m\u1edbi-trong-d\u1ef1-an-b\u1eb1ng-npm-init-w\"><span class=\"ez-toc-section\" id=\"Tao_workspace_moi_trong_du_an_bang_npm_init_-w\"><\/span><strong>T\u1ea1o workspace m\u1edbi trong d\u1ef1 \u00e1n b\u1eb1ng npm init -w<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>B\u1ea1n c\u00f3 th\u1ec3 t\u1ea1o m\u1ed9t workspace m\u1edbi trong d\u1ef1 \u00e1n c\u1ee7a m\u00ecnh b\u1eb1ng c\u00e1ch s\u1eed d\u1ee5ng t\u00f9y ch\u1ecdn c\u1ea5u h\u00ecnh workspace. D\u00f9ng l\u1ec7nh:&nbsp;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>npm init -w &lt;dir&gt;&nbsp;<\/code><\/pre>\n\n\n\n<p>Khi \u0111\u00f3, CLI (Command Line Interface) s\u1ebd t\u1ef1 \u0111\u1ed9ng t\u1ea1o th\u01b0 m\u1ee5c v\u00e0 c\u00e1c t\u1ec7p kh\u1edfi t\u1ea1o (boilerplate) c\u1ea7n thi\u1ebft, \u0111\u1ed3ng th\u1eddi th\u00eam tham chi\u1ebfu v\u00e0o ph\u1ea7n &#8220;workspaces&#8221;: [] trong t\u1ec7p package.json c\u1ee7a d\u1ef1 \u00e1n ch\u00ednh \u0111\u1ec3 \u0111\u1ea3m b\u1ea3o workspace m\u1edbi \u0111\u01b0\u1ee3c thi\u1ebft l\u1eadp \u0111\u00fang c\u00e1ch.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>L\u01b0u \u00fd: npm workspace ch\u1ec9 ho\u1ea1t \u0111\u1ed9ng \u0111\u1ed1i v\u1edbi npm v7 tr\u1edf l\u00ean. Do \u0111\u00f3, h\u00e3y \u0111\u1ea3m b\u1ea3o b\u1ea1n \u0111\u00e3 c\u1eadp nh\u1eadt npm tr\u01b0\u1edbc khi b\u1eaft \u0111\u1ea7u s\u1eed d\u1ee5ng t\u00ednh n\u0103ng n\u00e0y.<\/li>\n<\/ul>\n\n\n\n<p>M\u1ed9t v\u00ed d\u1ee5 v\u1ec1 npm workspace, b\u1ea1n c\u00f3 m\u1ed9t d\u1ef1 \u00e1n ch\u01b0a c\u00f3 workspace, c\u1ea5u tr\u00fac ban \u0111\u1ea7u nh\u01b0 sau:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>.\n\n+-- package.json<\/code><\/pre>\n\n\n\n<p>B\u1ea1n c\u00f3 th\u1ec3 t\u1ea1o m\u1ed9t workspace m\u1edbi b\u1eb1ng l\u1ec7nh:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>npm init -w packages\/a<\/code><\/pre>\n\n\n\n<p>L\u1ec7nh n\u00e0y s\u1ebd t\u1ea1o m\u1ed9t th\u01b0 m\u1ee5c m\u1edbi c\u00f9ng v\u1edbi t\u1ec7p package.json b\u00ean trong, \u0111\u1ed3ng th\u1eddi c\u1eadp nh\u1eadt package.json c\u1ea5p cao nh\u1ea5t \u0111\u1ec3 th\u00eam tham chi\u1ebfu \u0111\u1ebfn workspace m\u1edbi v\u1eeba t\u1ea1o. C\u1ea5u tr\u00fac sau khi th\u1ef1c hi\u1ec7n s\u1ebd tr\u1edf th\u00e0nh:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>.\n\n+-- package.json\n\n`-- packages\n\n\u00a0\u00a0\u00a0\u00a0`-- a\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0`-- package.json<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-kh\u1edfi-t\u1ea1o-workspace-v\u1edbi-trinh-kh\u1edfi-t\u1ea1o-initializer\"><strong>Kh\u1edfi t\u1ea1o workspace v\u1edbi tr\u00ecnh kh\u1edfi t\u1ea1o (initializer)<\/strong><\/h3>\n\n\n\n<p>L\u1ec7nh workspaces init c\u0169ng h\u1ed7 tr\u1ee3 c\u00fa ph\u00e1p:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>npm init &lt;initializer&gt; -w &lt;dir&gt;<\/code><\/pre>\n\n\n\n<p>C\u00fa ph\u00e1p n\u00e0y tu\u00e2n theo c\u00e1c quy t\u1eafc \u0111\u00e3 \u0111\u01b0\u1ee3c tr\u00ecnh b\u00e0y \u1edf ph\u1ea7n m\u00f4 t\u1ea3 ban \u0111\u1ea7u. V\u00ed d\u1ee5, n\u1ebfu b\u1ea1n mu\u1ed1n t\u1ea1o m\u1ed9t \u1ee9ng d\u1ee5ng React b\u1eb1ng c\u00f4ng c\u1ee5 create-react-app v\u00e0 \u0111\u1eb7t n\u00f3 l\u00e0m workspace con trong d\u1ef1 \u00e1n, b\u1ea1n c\u00f3 th\u1ec3 ch\u1ea1y l\u1ec7nh:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>npm init react-app -w packages\/my-react-app .<\/code><\/pre>\n\n\n\n<p>L\u1ec7nh n\u00e0y s\u1ebd \u0111\u1ea3m b\u1ea3o r\u1eb1ng \u1ee9ng d\u1ee5ng React c\u1ee7a b\u1ea1n \u0111\u01b0\u1ee3c t\u1ea1o \u0111\u00fang c\u00e1ch, n\u1eb1m trong th\u01b0 m\u1ee5c packages\/my-react-app, v\u00e0 t\u1ec7p package.json ch\u00ednh s\u1ebd \u0111\u01b0\u1ee3c c\u1ea5u h\u00ecnh \u0111\u1ec3 nh\u1eadn di\u1ec7n workspace n\u00e0y.<\/p>\n\n\n\n<p>M\u1ed9t \u0111i\u1ec3m c\u1ea7n l\u01b0u \u00fd l\u00e0 npm exec s\u1ebd \u0111\u01b0\u1ee3c th\u1ef1c thi trong ng\u1eef c\u1ea3nh c\u1ee7a th\u01b0 m\u1ee5c workspace m\u1edbi \u0111\u01b0\u1ee3c t\u1ea1o. Do \u0111\u00f3, trong v\u00ed d\u1ee5 tr\u00ean, ph\u1ea7n react-app . c\u00f3 ngh\u0129a l\u00e0 tr\u00ecnh kh\u1edfi t\u1ea1o s\u1ebd ch\u1ea1y trong th\u01b0 m\u1ee5c hi\u1ec7n t\u1ea1i c\u1ee7a workspace. C\u1ea5u tr\u00fac cu\u1ed1i c\u00f9ng c\u1ee7a d\u1ef1 \u00e1n sau khi kh\u1edfi t\u1ea1o s\u1ebd nh\u01b0 sau:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>.\n\n+-- package.json\n\n`-- packages\n\n\u00a0\u00a0\u00a0\u00a0+-- a\n\n\u00a0\u00a0\u00a0\u00a0| \u00a0 `-- package.json\n\n\u00a0\u00a0\u00a0\u00a0`-- my-react-app\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0+-- README\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0+-- package.json\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0`-- ...<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-th\u1ef1c-hanh-kh\u1edfi-t\u1ea1o-m\u1ed9t-d\u1ef1-an-node-jsv\u1edbi-npm-init\"><span class=\"ez-toc-section\" id=\"Thuc_hanh_khoi_tao_mot_du_an_Nodejsvoi_npm_init\"><\/span><strong>Th\u1ef1c h\u00e0nh kh\u1edfi t\u1ea1o m\u1ed9t d\u1ef1 \u00e1n Node.jsv\u1edbi npm init<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>\u0110\u1ec3 t\u1ea1o m\u1ed9t d\u1ef1 \u00e1n Node.js, l\u1ec7nh npm init \u0111\u01b0\u1ee3c s\u1eed d\u1ee5ng trong th\u01b0 m\u1ee5c m\u00e0 ng\u01b0\u1eddi d\u00f9ng mu\u1ed1n kh\u1edfi t\u1ea1o d\u1ef1 \u00e1n. D\u00f2ng l\u1ec7nh s\u1ebd hi\u1ec3n th\u1ecb m\u1ed9t lo\u1ea1t c\u00e2u h\u1ecfi nh\u01b0: t\u00ean d\u1ef1 \u00e1n, gi\u1ea5y ph\u00e9p (license), c\u00e1c script, m\u00f4 t\u1ea3, t\u00ean t\u00e1c gi\u1ea3, t\u1eeb kh\u00f3a, phi\u00ean b\u1ea3n hay t\u1ec7p ch\u00ednh (main file).<\/p>\n\n\n\n<p>Sau khi ho\u00e0n t\u1ea5t, npm s\u1ebd t\u1ea1o ra t\u1ec7p package.json trong th\u01b0 m\u1ee5c d\u1ef1 \u00e1n, \u0111\u00f3ng vai tr\u00f2 nh\u01b0 \u201cch\u1ee9ng nh\u1eadn\u201d r\u1eb1ng d\u1ef1 \u00e1n Node.js \u0111\u00e3 \u0111\u01b0\u1ee3c kh\u1edfi t\u1ea1o th\u00e0nh c\u00f4ng.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-b\u01b0\u1edbc-1-t\u1ea1o-\u1ee9ng-d\u1ee5ng-nodejs\"><strong>B\u01b0\u1edbc 1: T\u1ea1o \u1ee9ng d\u1ee5ng Nodejs<\/strong><\/h3>\n\n\n\n<p>Tr\u01b0\u1edbc khi b\u1eaft \u0111\u1ea7u ph\u00e1t tri\u1ec3n, b\u1ea1n c\u1ea7n kh\u1edfi t\u1ea1o m\u1ed9t d\u1ef1 \u00e1n <a href=\"https:\/\/itviec.com\/blog\/nodejs-la-gi\/\">Node.js<\/a> \u0111\u1ec3 thi\u1ebft l\u1eadp c\u1ea5u tr\u00fac c\u01a1 b\u1ea3n v\u00e0 t\u1ea1o t\u1ec7p package.json, n\u01a1i qu\u1ea3n l\u00fd to\u00e0n b\u1ed9 th\u00f4ng tin c\u1ee7a d\u1ef1 \u00e1n nh\u01b0 t\u00ean, phi\u00ean b\u1ea3n, script v\u00e0 dependencies.<\/p>\n\n\n\n<p>\u0110\u1ec3 l\u00e0m \u0111i\u1ec1u n\u00e0y, h\u00e3y m\u1edf Terminal ho\u1eb7c Command Prompt, di chuy\u1ec3n \u0111\u1ebfn th\u01b0 m\u1ee5c n\u01a1i b\u1ea1n mu\u1ed1n t\u1ea1o d\u1ef1 \u00e1n, r\u1ed3i nh\u1eadp l\u1ec7nh sau:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>npm init<\/code><\/pre>\n\n\n\n<p>L\u1ec7nh n\u00e0y s\u1ebd k\u00edch ho\u1ea1t tr\u00ecnh h\u01b0\u1edbng d\u1eabn (interactive prompt) gi\u00fap b\u1ea1n c\u00e0i \u0111\u1eb7t c\u00e1c th\u00f4ng tin ban \u0111\u1ea7u cho d\u1ef1 \u00e1n.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-b\u01b0\u1edbc-2-cai-d\u1eb7t-d\u1ef1-an\"><strong>B\u01b0\u1edbc 2: C\u00e0i \u0111\u1eb7t d\u1ef1 \u00e1n<\/strong><\/h3>\n\n\n\n<p>Sau khi ch\u1ea1y l\u1ec7nh tr\u00ean, npm s\u1ebd l\u1ea7n l\u01b0\u1ee3t \u0111\u01b0a ra c\u00e1c c\u00e2u h\u1ecfi li\u00ean quan \u0111\u1ebfn d\u1ef1 \u00e1n, ch\u1eb3ng h\u1ea1n nh\u01b0 t\u00ean g\u00f3i (package name), m\u00f4 t\u1ea3, t\u00e1c gi\u1ea3 hay gi\u1ea5y ph\u00e9p. B\u1ea1n c\u00f3 th\u1ec3:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Nh\u1ea5n Enter \u0111\u1ec3 ch\u1ecdn gi\u00e1 tr\u1ecb m\u1eb7c \u0111\u1ecbnh, ho\u1eb7c<\/li>\n\n\n\n<li>Nh\u1eadp gi\u00e1 tr\u1ecb t\u00f9y ch\u1ec9nh ph\u00f9 h\u1ee3p v\u1edbi d\u1ef1 \u00e1n c\u1ee7a m\u00ecnh.<\/li>\n<\/ul>\n\n\n\n<p>V\u00ed d\u1ee5 minh h\u1ecda trong PowerShell:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>PS D:\\ITviec\\Demo> npm init\nThis utility will walk you through creating a package.json file.\nIt only covers the most common items, and tries to guess sensible defaults.\n\nSee `npm help init` for definitive documentation on these fields\nand exactly what they do.\n\nUse `npm install &lt;pkg>` afterwards to install a package and\nsave it as a dependency in the package.json file.\n\nPress ^C at any time to quit.\npackage name: (demo)\nversion: (1.0.0)\ndescription: \"Tutorial For npm init\"\nentry point: (index.js) app.js\ntest command:\ngit repository:\nkeywords: ITviec, Nodejs\nauthor: ITviec\nlicense: (ISC) MIT\nAbout to write to D:\\ITviec\\Demo\\package.json:\n\n{\n     \"name\": \"demo\",\n     \"version\": \"1.0.0\",\n     \"description\": \"\\\"Tutorial For npm init\\\"\",\n     \"main\": \"app.js\",\n     \"scripts\": {\n      \"test\": \"echo \\\"Error: no test specified\\\" &amp;&amp; exit 1\"\n     },\n     \"keywords\": &#91;\n         \"ITviec\",\n         \"Nodejs\"\n     ],\n     \"author\": \"Itviec\",\n    \"license\": \"MIT\"\n}\n\nIs this OK? (yes)<\/code><\/pre>\n\n\n\n<p>Ch\u1ec9 c\u1ea7n nh\u1eadp yes, qu\u00e1 tr\u00ecnh kh\u1edfi t\u1ea1o s\u1ebd ho\u00e0n t\u1ea5t. Khi \u0111\u00f3, t\u1ec7p package.json s\u1ebd \u0111\u01b0\u1ee3c t\u1ea1o trong th\u01b0 m\u1ee5c d\u1ef1 \u00e1n. \u0110\u00e1nh d\u1ea5u vi\u1ec7c b\u1ea1n \u0111\u00e3 ch\u00ednh th\u1ee9c kh\u1edfi \u0111\u1ed9ng m\u1ed9t \u1ee9ng d\u1ee5ng Node.js v\u1edbi \u0111\u1ea7y \u0111\u1ee7 c\u1ea5u h\u00ecnh c\u01a1 b\u1ea3n.<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p><em>\u0110\u1ecdc chi ti\u1ebft: <strong><a href=\"https:\/\/itviec.com\/blog\/huong-dan-npm-install\/\" target=\"_blank\" rel=\"noreferrer noopener\">NPM install: H\u01b0\u1edbng d\u1eabn c\u00e1ch c\u00e0i \u0111\u1eb7t v\u00e0 qu\u1ea3n l\u00fd c\u00e1c g\u00f3i package<\/a><\/strong><\/em><\/p>\n<\/blockquote>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-thi\u1ebft-l\u1eadp-tuy-ch\u1ecdn-c\u1ea5u-hinh-cho-l\u1ec7nh-npm-init\"><span class=\"ez-toc-section\" id=\"Thiet_lap_tuy_chon_cau_hinh_cho_lenh_npm_init\"><\/span><strong>Thi\u1ebft l\u1eadp t\u00f9y ch\u1ecdn c\u1ea5u h\u00ecnh cho l\u1ec7nh npm init<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Tr\u00ecnh qu\u1ea3n l\u00fd g\u00f3i Node Package Manager (npm) cho ph\u00e9p b\u1ea1n thi\u1ebft l\u1eadp c\u00e1c t\u00f9y ch\u1ecdn c\u1ea5u h\u00ecnh m\u1eb7c \u0111\u1ecbnh cho l\u1ec7nh npm init. D\u01b0\u1edbi \u0111\u00e2y l\u00e0 m\u1ed9t s\u1ed1 l\u1ec7nh b\u1ea1n c\u00f3 th\u1ec3 s\u1eed d\u1ee5ng \u0111\u1ec3 c\u00e0i \u0111\u1eb7t c\u00e1c gi\u00e1 tr\u1ecb m\u1eb7c \u0111\u1ecbnh n\u00e0y.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-thi\u1ebft-l\u1eadp-d\u1ecba-ch\u1ec9-email-c\u1ee7a-tac-gi\u1ea3\"><strong>Thi\u1ebft l\u1eadp \u0111\u1ecba ch\u1ec9 email c\u1ee7a t\u00e1c gi\u1ea3<\/strong><\/h3>\n\n\n\n<p>Khi kh\u1edfi t\u1ea1o m\u1ed9t d\u1ef1 \u00e1n Node.js b\u1eb1ng <code>npm init<\/code>, b\u1ea1n c\u00f3 th\u1ec3 \u0111\u01b0\u1ee3c y\u00eau c\u1ea7u nh\u1eadp th\u00f4ng tin t\u00e1c gi\u1ea3 (author) \u2013 bao g\u1ed3m t\u00ean v\u00e0 \u0111\u1ecba ch\u1ec9 email. \u0110\u1ec3 ti\u1ebft ki\u1ec7m th\u1eddi gian cho nh\u1eefng l\u1ea7n kh\u1edfi t\u1ea1o sau, npm cho ph\u00e9p b\u1ea1n \u0111\u1eb7t gi\u00e1 tr\u1ecb m\u1eb7c \u0111\u1ecbnh cho email c\u1ee7a t\u00e1c gi\u1ea3.\u00a0<\/p>\n\n\n\n<p>Vi\u1ec7c n\u00e0y gi\u00fap m\u1ecdi t\u1ec7p package.json m\u1edbi t\u1ef1 \u0111\u1ed9ng \u0111i\u1ec1n th\u00f4ng tin ch\u00ednh x\u00e1c m\u00e0 kh\u00f4ng c\u1ea7n nh\u1eadp l\u1ea1i th\u1ee7 c\u00f4ng. L\u1ec7nh sau gi\u00fap b\u1ea1n \u0111\u1eb7t \u0111\u1ecba ch\u1ec9 email m\u1eb7c \u0111\u1ecbnh cho d\u1ef1 \u00e1n:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>npm set init.author.email \"nh\u1eadp \u0111\u1ecba ch\u1ec9 email c\u1ee7a b\u1ea1n t\u1ea1i \u0111\u00e2y\"<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-cai-d\u1eb7t-ten-tac-gi\u1ea3\"><strong>C\u00e0i \u0111\u1eb7t t\u00ean t\u00e1c gi\u1ea3<\/strong><\/h3>\n\n\n\n<p>T\u01b0\u01a1ng t\u1ef1 nh\u01b0 \u0111\u1ecba ch\u1ec9 email, t\u00ean t\u00e1c gi\u1ea3 s\u1ebd \u0111\u01b0\u1ee3c hi\u1ec3n th\u1ecb trong package.json, gi\u00fap x\u00e1c \u0111\u1ecbnh ng\u01b0\u1eddi ph\u00e1t tri\u1ec3n ho\u1eb7c ng\u01b0\u1eddi ch\u1ecbu tr\u00e1ch nhi\u1ec7m cho g\u00f3i (package). \u0110\u1ec3 tr\u00e1nh ph\u1ea3i nh\u1eadp l\u1ea1i m\u1ed7i l\u1ea7n t\u1ea1o d\u1ef1 \u00e1n m\u1edbi, b\u1ea1n c\u00f3 th\u1ec3 \u0111\u1eb7t t\u00ean t\u00e1c gi\u1ea3 m\u1eb7c \u0111\u1ecbnh b\u1eb1ng l\u1ec7nh sau.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>npm set init.author.name \"nh\u1eadp t\u00ean t\u00e1c gi\u1ea3 c\u1ee7a b\u1ea1n t\u1ea1i \u0111\u00e2y\"<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-cai-d\u1eb7t-gi\u1ea5y-phep-license-cho-d\u1ef1-an\"><strong>C\u00e0i \u0111\u1eb7t gi\u1ea5y ph\u00e9p (license) cho d\u1ef1 \u00e1n<\/strong><\/h3>\n\n\n\n<p>Trong m\u1ed7i t\u1ec7p package.json, tr\u01b0\u1eddng license cho bi\u1ebft \u0111i\u1ec1u ki\u1ec7n s\u1eed d\u1ee5ng, ph\u00e2n ph\u1ed1i v\u00e0 ch\u1ec9nh s\u1eeda m\u00e3 ngu\u1ed3n c\u1ee7a d\u1ef1 \u00e1n. Vi\u1ec7c khai b\u00e1o gi\u1ea5y ph\u00e9p gi\u00fap \u0111\u1ea3m b\u1ea3o minh b\u1ea1ch ph\u00e1p l\u00fd v\u00e0 kh\u1eb3ng \u0111\u1ecbnh quy\u1ec1n s\u1edf h\u1eefu m\u00e3 ngu\u1ed3n. Thay v\u00ec ph\u1ea3i nh\u1eadp th\u1ee7 c\u00f4ng m\u1ed7i l\u1ea7n, b\u1ea1n c\u00f3 th\u1ec3 thi\u1ebft l\u1eadp s\u1eb5n lo\u1ea1i gi\u1ea5y ph\u00e9p m\u1eb7c \u0111\u1ecbnh cho t\u1ea5t c\u1ea3 c\u00e1c d\u1ef1 \u00e1n m\u1edbi b\u1eb1ng l\u1ec7nh.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>npm set init.license \"MIT\"<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-cach-them-dependencies-th\u1ee7-cong-vao-t\u1ec7p-package-json\"><strong>C\u00e1ch th\u00eam dependencies th\u1ee7 c\u00f4ng v\u00e0o t\u1ec7p package.json<\/strong><\/h3>\n\n\n\n<p>B\u1ea1n c\u00f3 th\u1ec3 s\u1eed d\u1ee5ng thu\u1ed9c t\u00ednh dependencies \u0111\u1ec3 th\u00eam th\u1ee7 c\u00f4ng c\u00e1c g\u00f3i ph\u1ee5 thu\u1ed9c (dependencies) v\u00e0o t\u1ec7p package.json b\u1eb1ng b\u1ea5t k\u1ef3 tr\u00ecnh so\u1ea1n th\u1ea3o v\u0103n b\u1ea3n n\u00e0o nh\u01b0 Microsoft Visual Studio Code.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>{\n\n\u00a0\u00a0\"name\": \"hometech\",\n\n\u00a0\u00a0\"version\": \"1.0.0\",\n\n\u00a0\u00a0\"dependencies\": {\n\n\u00a0\u00a0\u00a0\u00a0\"my_dep\": \"^1.0.0\"\n\n\u00a0\u00a0}\n\n}<\/code><\/pre>\n\n\n\n<p>T\u01b0\u01a1ng t\u1ef1, b\u1ea1n c\u00f3 th\u1ec3 s\u1eed d\u1ee5ng thu\u1ed9c t\u00ednh devDependencies \u0111\u1ec3 th\u00eam c\u00e1c g\u00f3i d\u00e0nh cho m\u00f4i tr\u01b0\u1eddng ph\u00e1t tri\u1ec3n (development dependencies) c\u00f9ng t\u00ean v\u00e0 phi\u00ean b\u1ea3n c\u1ee7a ch\u00fang v\u00e0o package.json:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>{\n\n\u00a0\u00a0\"name\": \"hometech\",\n\n\u00a0\u00a0\"version\": \"1.0.0\",\n\n\u00a0\u00a0\"dependencies\": {\n\n\u00a0\u00a0\u00a0\u00a0\"my_dep\": \"^1.0.0\"\n\n\u00a0\u00a0},\n\n\u00a0\u00a0\"devDependencies\": {\n\n\u00a0\u00a0\u00a0\u00a0\"my_test_framework\": \"^3.1.0\",\n\n\u00a0\u00a0\u00a0\u00a0\"another_dev_dep\": \"1.0.0 - 1.2.0\"\n\n\u00a0\u00a0}\n\n}<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-cac-cau-h\u1ecfi-th\u01b0\u1eddng-g\u1eb7p-v\u1ec1-npm-init\"><span class=\"ez-toc-section\" id=\"Cac_cau_hoi_thuong_gap_ve_npm_init\"><\/span><strong>C\u00e1c c\u00e2u h\u1ecfi th\u01b0\u1eddng g\u1eb7p v\u1ec1 npm init<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-cach-ch\u1ea1y-l\u1ec7nh-npm-init-trong-vs-code-nh\u01b0-th\u1ebf-nao\"><strong>C\u00e1ch ch\u1ea1y l\u1ec7nh npm init trong VS Code nh\u01b0 th\u1ebf n\u00e0o?<\/strong><\/h3>\n\n\n\n<p>\u0110\u1ec3 ch\u1ea1y npm init trong Visual Studio Code, b\u1ea1n ch\u1ec9 c\u1ea7n m\u1edf Terminal b\u1eb1ng t\u1ed5 h\u1ee3p ph\u00edm Ctrl + ~ (ho\u1eb7c v\u00e0o menu View \u2192 Terminal), sau \u0111\u00f3 di chuy\u1ec3n \u0111\u1ebfn th\u01b0 m\u1ee5c d\u1ef1 \u00e1n c\u1ee7a b\u1ea1n v\u00e0 g\u00f5 l\u1ec7nh:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>npm init<\/code><\/pre>\n\n\n\n<p>Ti\u1ebfp theo, VS Code s\u1ebd hi\u1ec3n th\u1ecb c\u00e1c c\u00e2u h\u1ecfi \u0111\u1ec3 b\u1ea1n nh\u1eadp th\u00f4ng tin nh\u01b0 t\u00ean d\u1ef1 \u00e1n, phi\u00ean b\u1ea3n, m\u00f4 t\u1ea3,\u2026 Sau khi ho\u00e0n t\u1ea5t, t\u1ec7p package.json s\u1ebd \u0111\u01b0\u1ee3c t\u1ea1o t\u1ef1 \u0111\u1ed9ng trong th\u01b0 m\u1ee5c hi\u1ec7n t\u1ea1i. N\u1ebfu mu\u1ed1n kh\u1edfi t\u1ea1o nhanh m\u00e0 kh\u00f4ng c\u1ea7n tr\u1ea3 l\u1eddi t\u1eebng c\u00e2u h\u1ecfi, b\u1ea1n c\u00f3 th\u1ec3 d\u00f9ng l\u1ec7nh:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>npm init -y<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-cach-s\u1eed-d\u1ee5ng-npm-init-nh\u01b0-th\u1ebf-nao\"><strong>C\u00e1ch s\u1eed d\u1ee5ng npm init nh\u01b0 th\u1ebf n\u00e0o?<\/strong><\/h3>\n\n\n\n<p>L\u1ec7nh npm init \u0111\u01b0\u1ee3c d\u00f9ng \u0111\u1ec3 t\u1ea1o t\u1ec7p package.json, \u0111\u00e2y l\u00e0 t\u1ec7p c\u1ea5u h\u00ecnh trung t\u00e2m c\u1ee7a m\u1ecdi d\u1ef1 \u00e1n Node.js. Khi g\u00f5 npm init trong terminal, b\u1ea1n s\u1ebd \u0111\u01b0\u1ee3c h\u01b0\u1edbng d\u1eabn \u0111i\u1ec1n c\u00e1c th\u00f4ng tin c\u01a1 b\u1ea3n nh\u01b0:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>name:<\/strong> T\u00ean g\u00f3i ho\u1eb7c d\u1ef1 \u00e1n.<\/li>\n\n\n\n<li><strong>version: <\/strong>Phi\u00ean b\u1ea3n hi\u1ec7n t\u1ea1i.<\/li>\n\n\n\n<li><strong>description: <\/strong>M\u00f4 t\u1ea3 ng\u1eafn v\u1ec1 d\u1ef1 \u00e1n.<\/li>\n\n\n\n<li><strong>entry point: <\/strong>T\u1ec7p ch\u00ednh (th\u01b0\u1eddng l\u00e0 index.js).<\/li>\n\n\n\n<li><strong>scripts<\/strong>:<strong> <\/strong>C\u00e1c l\u1ec7nh npm c\u00f3 th\u1ec3 ch\u1ea1y t\u1ef1 \u0111\u1ed9ng.<\/li>\n<\/ul>\n\n\n\n<p>Sau khi ho\u00e0n th\u00e0nh, npm s\u1ebd t\u1ea1o ra t\u1ec7p package.json ch\u1ee9a to\u00e0n b\u1ed9 d\u1eef li\u1ec7u n\u00e0y. N\u1ebfu mu\u1ed1n b\u1ecf qua c\u00e1c b\u01b0\u1edbc nh\u1eadp th\u00f4ng tin, b\u1ea1n ch\u1ec9 c\u1ea7n d\u00f9ng l\u1ec7nh npm init -y \u0111\u1ec3 t\u1ea1o t\u1ec7p m\u1eb7c \u0111\u1ecbnh nhanh ch\u00f3ng.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-npm-init-trong-windows-co-ho\u1ea1t-d\u1ed9ng-khac-tren-macos-linux-khong\"><strong>npm init trong Windows c\u00f3 ho\u1ea1t \u0111\u1ed9ng kh\u00e1c tr\u00ean macOS, Linux kh\u00f4ng?<\/strong><\/h3>\n\n\n\n<p>Tr\u00ean Windows, l\u1ec7nh npm init c\u00f3 ch\u1ee9c n\u0103ng ho\u00e0n to\u00e0n gi\u1ed1ng nh\u01b0 tr\u00ean macOS ho\u1eb7c Linux. B\u1ea1n c\u00f3 th\u1ec3 m\u1edf Command Prompt, PowerShell ho\u1eb7c terminal trong VS Code, di chuy\u1ec3n \u0111\u1ebfn th\u01b0 m\u1ee5c d\u1ef1 \u00e1n r\u1ed3i nh\u1eadp c\u00e2u l\u1ec7nh:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>npm init<\/code><\/pre>\n\n\n\n<p>Sau \u0111\u00f3, ti\u1ebfn h\u00e0nh t\u1ea1o t\u1ec7p package.json. N\u1ebfu b\u1ea1n mu\u1ed1n b\u1ecf qua ph\u1ea7n nh\u1eadp th\u1ee7 c\u00f4ng, h\u00e3y s\u1eed d\u1ee5ng c\u00e2u l\u1ec7nh:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>npm init -y<\/code><\/pre>\n\n\n\n<p>C\u00fa ph\u00e1p v\u00e0 k\u1ebft qu\u1ea3 c\u1ee7a l\u1ec7nh n\u00e0y kh\u00f4ng ph\u1ee5 thu\u1ed9c v\u00e0o h\u1ec7 \u0111i\u1ec1u h\u00e0nh, n\u00ean b\u1ea1n c\u00f3 th\u1ec3 y\u00ean t\u00e2m d\u00f9ng tr\u00ean m\u1ecdi n\u1ec1n t\u1ea3ng h\u1ed7 tr\u1ee3 Node.js.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-t\u1ed5ng-k\u1ebft\"><span class=\"ez-toc-section\" id=\"Tong_ket\"><\/span><strong>T\u1ed5ng k\u1ebft<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p><strong>npm init <\/strong>kh\u00f4ng ch\u1ec9 l\u00e0 b\u01b0\u1edbc \u0111\u1ea7u ti\u00ean khi b\u1eaft \u0111\u1ea7u d\u1ef1 \u00e1n Node.js m\u00e0 c\u00f2n l\u00e0 n\u1ec1n t\u1ea3ng \u0111\u1ec3 \u0111\u1ea3m b\u1ea3o c\u1ea5u tr\u00fac d\u1ef1 \u00e1n khoa h\u1ecdc v\u00e0 d\u1ec5 qu\u1ea3n l\u00fd. Vi\u1ec7c hi\u1ec3u r\u00f5 c\u00e1c t\u00f9y ch\u1ecdn v\u00e0 c\u00fa ph\u00e1p c\u1ee7a npm init gi\u00fap b\u1ea1n ti\u1ebft ki\u1ec7m th\u1eddi gian, tr\u00e1nh l\u1ed7i c\u1ea5u h\u00ecnh, v\u00e0 t\u1ed1i \u01b0u workflow ph\u00e1t tri\u1ec3n. Hy v\u1ecdng qua b\u00e0i vi\u1ebft, b\u1ea1n c\u00f3 th\u1ec3 \u00e1p d\u1ee5ng \u0111\u01b0\u1ee3c c\u00e1c m\u1eb9o \u0111\u00e3 \u0111\u01b0\u1ee3c chia s\u1ebb \u0111\u1ec3 thi\u1ebft l\u1eadp d\u1ef1 \u00e1n Node.js m\u1ed9t c\u00e1ch nhanh ch\u00f3ng, linh ho\u1ea1t v\u00e0 theo \u0111\u00fang ti\u00eau chu\u1ea9n chuy\u00ean nghi\u1ec7p.<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p><em>\u0110\u1ecdc chi ti\u1ebft: <strong><a href=\"https:\/\/itviec.com\/blog\/nodejs-backend-la-gi\/\" target=\"_blank\" rel=\"noreferrer noopener\">Khi n\u00e0o n\u00ean s\u1eed d\u1ee5ng NodeJS l\u1eadp tr\u00ecnh backend?<\/a><\/strong><\/em><\/p>\n<\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>npm init l\u00e0 l\u1ec7nh c\u01a1 b\u1ea3n nh\u01b0ng c\u1ef1c k\u1ef3 quan tr\u1ecdng trong quy tr\u00ecnh kh\u1edfi t\u1ea1o m\u1ed9t d\u1ef1 \u00e1n Node.js. L\u1ec7nh n\u00e0y gi\u00fap l\u1eadp tr\u00ecnh vi\u00ean t\u1ea1o t\u1ec7p package.json, n\u01a1i l\u01b0u tr\u1eef th\u00f4ng tin v\u1ec1 t\u00ean, phi\u00ean b\u1ea3n, dependencies v\u00e0 script. Khi ch\u1ea1y npm init, ng\u01b0\u1eddi d\u00f9ng s\u1ebd \u0111\u01b0\u1ee3c h\u01b0\u1edbng d\u1eabn qua t\u1eebng b\u01b0\u1edbc nh\u1eadp [&hellip;]<\/p>\n","protected":false},"author":95,"featured_media":93928,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_gspb_post_css":"","footnotes":""},"categories":[109,10344],"tags":[],"class_list":["post-93917","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-chuyen-mon-it","category-javascript"],"blocksy_meta":[],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v26.8 (Yoast SEO v27.8) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>NPM init: H\u01b0\u1edbng d\u1eabn c\u00e1ch d\u00f9ng l\u1ec7nh kh\u1edfi t\u1ea1o d\u1ef1 \u00e1n Node.js - ITviec Blog<\/title>\n<meta name=\"description\" content=\"H\u01b0\u1edbng d\u1eabn s\u1eed d\u1ee5ng k\u00e8m v\u00ed d\u1ee5 chi ti\u1ebft l\u1ec7nh npm init. \u0110\u00e2y l\u00e0 l\u1ec7nh kh\u1edfi t\u1ea1o d\u1ef1 \u00e1n Node.js, gi\u00fap t\u1ea1o t\u1ec7p package.json ch\u1ee9a th\u00f4ng tin c\u1ea7n thi\u1ebft.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/itviec.com\/blog\/huong-dan-npm-init\/\" \/>\n<meta property=\"og:locale\" content=\"vi_VN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"NPM init: H\u01b0\u1edbng d\u1eabn c\u00e1ch d\u00f9ng l\u1ec7nh kh\u1edfi t\u1ea1o d\u1ef1 \u00e1n Node.js\" \/>\n<meta property=\"og:description\" content=\"npm init l\u00e0 l\u1ec7nh c\u01a1 b\u1ea3n nh\u01b0ng c\u1ef1c k\u1ef3 quan tr\u1ecdng trong quy tr\u00ecnh kh\u1edfi t\u1ea1o m\u1ed9t d\u1ef1 \u00e1n Node.js. L\u1ec7nh n\u00e0y gi\u00fap l\u1eadp tr\u00ecnh vi\u00ean t\u1ea1o t\u1ec7p package.json, n\u01a1i l\u01b0u tr\u1eef\" \/>\n<meta property=\"og:url\" content=\"https:\/\/itviec.com\/blog\/huong-dan-npm-init\/\" \/>\n<meta property=\"og:site_name\" content=\"ITviec Blog\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/ITviec\" \/>\n<meta property=\"article:published_time\" content=\"2025-12-30T08:10:09+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-12-30T08:10:11+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/itviec.com\/blog\/wp-content\/uploads\/2025\/12\/npm-init-scaled.png\" \/>\n\t<meta property=\"og:image:width\" content=\"800\" \/>\n\t<meta property=\"og:image:height\" content=\"421\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Tuong Uyen\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@ITviec\" \/>\n<meta name=\"twitter:site\" content=\"@ITviec\" \/>\n<meta name=\"twitter:label1\" content=\"\u0110\u01b0\u1ee3c vi\u1ebft b\u1edfi\" \/>\n\t<meta name=\"twitter:data1\" content=\"Tuong Uyen\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u01af\u1edbc t\u00ednh th\u1eddi gian \u0111\u1ecdc\" \/>\n\t<meta name=\"twitter:data2\" content=\"14 ph\u00fat\" \/>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"NPM init: H\u01b0\u1edbng d\u1eabn c\u00e1ch d\u00f9ng l\u1ec7nh kh\u1edfi t\u1ea1o d\u1ef1 \u00e1n Node.js - ITviec Blog","description":"H\u01b0\u1edbng d\u1eabn s\u1eed d\u1ee5ng k\u00e8m v\u00ed d\u1ee5 chi ti\u1ebft l\u1ec7nh npm init. \u0110\u00e2y l\u00e0 l\u1ec7nh kh\u1edfi t\u1ea1o d\u1ef1 \u00e1n Node.js, gi\u00fap t\u1ea1o t\u1ec7p package.json ch\u1ee9a th\u00f4ng tin c\u1ea7n thi\u1ebft.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/itviec.com\/blog\/huong-dan-npm-init\/","og_locale":"vi_VN","og_type":"article","og_title":"NPM init: H\u01b0\u1edbng d\u1eabn c\u00e1ch d\u00f9ng l\u1ec7nh kh\u1edfi t\u1ea1o d\u1ef1 \u00e1n Node.js","og_description":"npm init l\u00e0 l\u1ec7nh c\u01a1 b\u1ea3n nh\u01b0ng c\u1ef1c k\u1ef3 quan tr\u1ecdng trong quy tr\u00ecnh kh\u1edfi t\u1ea1o m\u1ed9t d\u1ef1 \u00e1n Node.js. L\u1ec7nh n\u00e0y gi\u00fap l\u1eadp tr\u00ecnh vi\u00ean t\u1ea1o t\u1ec7p package.json, n\u01a1i l\u01b0u tr\u1eef","og_url":"https:\/\/itviec.com\/blog\/huong-dan-npm-init\/","og_site_name":"ITviec Blog","article_publisher":"https:\/\/www.facebook.com\/ITviec","article_published_time":"2025-12-30T08:10:09+00:00","article_modified_time":"2025-12-30T08:10:11+00:00","og_image":[{"width":800,"height":421,"url":"https:\/\/itviec.com\/blog\/wp-content\/uploads\/2025\/12\/npm-init-scaled.png","type":"image\/png"}],"author":"Tuong Uyen","twitter_card":"summary_large_image","twitter_creator":"@ITviec","twitter_site":"@ITviec","twitter_misc":{"\u0110\u01b0\u1ee3c vi\u1ebft b\u1edfi":"Tuong Uyen","\u01af\u1edbc t\u00ednh th\u1eddi gian \u0111\u1ecdc":"14 ph\u00fat"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/itviec.com\/blog\/huong-dan-npm-init\/#article","isPartOf":{"@id":"https:\/\/itviec.com\/blog\/huong-dan-npm-init\/"},"author":{"name":"Tuong Uyen","@id":"https:\/\/itviec.com\/blog\/#\/schema\/person\/e97d0e359f8840eaea7dc3a96006a8d4"},"headline":"NPM init: H\u01b0\u1edbng d\u1eabn c\u00e1ch d\u00f9ng l\u1ec7nh kh\u1edfi t\u1ea1o d\u1ef1 \u00e1n Node.js","datePublished":"2025-12-30T08:10:09+00:00","dateModified":"2025-12-30T08:10:11+00:00","mainEntityOfPage":{"@id":"https:\/\/itviec.com\/blog\/huong-dan-npm-init\/"},"wordCount":3744,"publisher":{"@id":"https:\/\/itviec.com\/blog\/#organization"},"image":{"@id":"https:\/\/itviec.com\/blog\/huong-dan-npm-init\/#primaryimage"},"thumbnailUrl":"https:\/\/itviec.com\/blog\/wp-content\/uploads\/2025\/12\/npm-init-scaled.png","articleSection":["Chuy\u00ean m\u00f4n IT","JavaScript"],"inLanguage":"vi"},{"@type":"WebPage","@id":"https:\/\/itviec.com\/blog\/huong-dan-npm-init\/","url":"https:\/\/itviec.com\/blog\/huong-dan-npm-init\/","name":"NPM init: H\u01b0\u1edbng d\u1eabn c\u00e1ch d\u00f9ng l\u1ec7nh kh\u1edfi t\u1ea1o d\u1ef1 \u00e1n Node.js - ITviec Blog","isPartOf":{"@id":"https:\/\/itviec.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/itviec.com\/blog\/huong-dan-npm-init\/#primaryimage"},"image":{"@id":"https:\/\/itviec.com\/blog\/huong-dan-npm-init\/#primaryimage"},"thumbnailUrl":"https:\/\/itviec.com\/blog\/wp-content\/uploads\/2025\/12\/npm-init-scaled.png","datePublished":"2025-12-30T08:10:09+00:00","dateModified":"2025-12-30T08:10:11+00:00","description":"H\u01b0\u1edbng d\u1eabn s\u1eed d\u1ee5ng k\u00e8m v\u00ed d\u1ee5 chi ti\u1ebft l\u1ec7nh npm init. \u0110\u00e2y l\u00e0 l\u1ec7nh kh\u1edfi t\u1ea1o d\u1ef1 \u00e1n Node.js, gi\u00fap t\u1ea1o t\u1ec7p package.json ch\u1ee9a th\u00f4ng tin c\u1ea7n thi\u1ebft.","breadcrumb":{"@id":"https:\/\/itviec.com\/blog\/huong-dan-npm-init\/#breadcrumb"},"inLanguage":"vi","potentialAction":[{"@type":"ReadAction","target":["https:\/\/itviec.com\/blog\/huong-dan-npm-init\/"]}]},{"@type":"ImageObject","inLanguage":"vi","@id":"https:\/\/itviec.com\/blog\/huong-dan-npm-init\/#primaryimage","url":"https:\/\/itviec.com\/blog\/wp-content\/uploads\/2025\/12\/npm-init-scaled.png","contentUrl":"https:\/\/itviec.com\/blog\/wp-content\/uploads\/2025\/12\/npm-init-scaled.png","width":800,"height":421,"caption":"npm init - itviec blog"},{"@type":"BreadcrumbList","@id":"https:\/\/itviec.com\/blog\/huong-dan-npm-init\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Chuy\u00ean m\u00f4n IT","item":"https:\/\/itviec.com\/blog\/chuyen-mon-it\/"},{"@type":"ListItem","position":2,"name":"NPM init: H\u01b0\u1edbng d\u1eabn c\u00e1ch d\u00f9ng l\u1ec7nh kh\u1edfi t\u1ea1o d\u1ef1 \u00e1n Node.js"}]},{"@type":"WebSite","@id":"https:\/\/itviec.com\/blog\/#website","url":"https:\/\/itviec.com\/blog\/","name":"ITviec Blog","description":"IT Jobs &amp; People in Vietnam","publisher":{"@id":"https:\/\/itviec.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/itviec.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"vi"},{"@type":"Organization","@id":"https:\/\/itviec.com\/blog\/#organization","name":"ITviec","url":"https:\/\/itviec.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"vi","@id":"https:\/\/itviec.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/itviec.com\/blog\/wp-content\/uploads\/2018\/12\/itviec-black-square-facebook.png","contentUrl":"https:\/\/itviec.com\/blog\/wp-content\/uploads\/2018\/12\/itviec-black-square-facebook.png","width":1800,"height":1800,"caption":"ITviec"},"image":{"@id":"https:\/\/itviec.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/ITviec","https:\/\/x.com\/ITviec","https:\/\/www.linkedin.com\/company\/itviec","https:\/\/www.youtube.com\/channel\/UCYthAQ3bcGr57M_ag5gHDvQ"]},{"@type":"Person","@id":"https:\/\/itviec.com\/blog\/#\/schema\/person\/e97d0e359f8840eaea7dc3a96006a8d4","name":"Tuong Uyen","image":{"@type":"ImageObject","inLanguage":"vi","@id":"https:\/\/itviec.com\/blog\/wp-content\/uploads\/2022\/10\/tuong-uyen-profile-picture-100x100.jpg","url":"https:\/\/itviec.com\/blog\/wp-content\/uploads\/2022\/10\/tuong-uyen-profile-picture-100x100.jpg","contentUrl":"https:\/\/itviec.com\/blog\/wp-content\/uploads\/2022\/10\/tuong-uyen-profile-picture-100x100.jpg","caption":"Tuong Uyen"},"url":"https:\/\/itviec.com\/blog\/author\/tuong-uyen-pikachu\/"}]}},"_links":{"self":[{"href":"https:\/\/itviec.com\/blog\/wp-json\/wp\/v2\/posts\/93917","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/itviec.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/itviec.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/itviec.com\/blog\/wp-json\/wp\/v2\/users\/95"}],"replies":[{"embeddable":true,"href":"https:\/\/itviec.com\/blog\/wp-json\/wp\/v2\/comments?post=93917"}],"version-history":[{"count":1,"href":"https:\/\/itviec.com\/blog\/wp-json\/wp\/v2\/posts\/93917\/revisions"}],"predecessor-version":[{"id":93929,"href":"https:\/\/itviec.com\/blog\/wp-json\/wp\/v2\/posts\/93917\/revisions\/93929"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/itviec.com\/blog\/wp-json\/wp\/v2\/media\/93928"}],"wp:attachment":[{"href":"https:\/\/itviec.com\/blog\/wp-json\/wp\/v2\/media?parent=93917"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/itviec.com\/blog\/wp-json\/wp\/v2\/categories?post=93917"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/itviec.com\/blog\/wp-json\/wp\/v2\/tags?post=93917"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}