{"id":72660,"date":"2020-01-14T16:35:21","date_gmt":"2020-01-14T11:05:21","guid":{"rendered":"https:\/\/www.vskills.in\/certification\/tutorial\/?p=72660"},"modified":"2024-04-12T14:22:58","modified_gmt":"2024-04-12T08:52:58","slug":"core-modules","status":"publish","type":"page","link":"https:\/\/www.vskills.in\/certification\/tutorial\/core-modules\/","title":{"rendered":"Core Modules"},"content":{"rendered":"<p>Node.js has several modules compiled into the binary. The core modules are defined within Node.js&#8217;s source and are located in the lib\/ folder.<\/p>\n<p>Core modules are always preferentially loaded if their identifier is passed to require(). For instance, require(&#8216;http&#8217;) will always return the built in HTTP module, even if there is a file by that name.<\/p>\n<h3>Node.js Core Modules<\/h3>\n<p>Node.js is a light weight framework. The core modules include bare minimum functionalities of Node.js. These core modules are compiled into its binary distribution and load automatically when Node.js process starts. However, you need to import the core module first in order to use it in your application. The following table lists some of the important core modules in Node.js.<\/p>\n<table>\n<thead>\n<tr>\n<td width=\"112\"><strong>Core Module <\/strong><\/td>\n<td width=\"521\"><strong>Description<\/strong><\/td>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td width=\"112\">http<\/td>\n<td width=\"521\">http module includes classes, methods and events to create Node.js http server.<\/td>\n<\/tr>\n<tr>\n<td width=\"112\">url<\/td>\n<td width=\"521\">url module includes methods for URL resolution and parsing.<\/td>\n<\/tr>\n<tr>\n<td width=\"112\">querystring<\/td>\n<td width=\"521\">querystring module includes methods to deal with query string.<\/td>\n<\/tr>\n<tr>\n<td width=\"112\">path<\/td>\n<td width=\"521\">path module includes methods to deal with file paths.<\/td>\n<\/tr>\n<tr>\n<td width=\"112\">fs<\/td>\n<td width=\"521\">fs module includes classes, methods, and events to work with file I\/O.<\/td>\n<\/tr>\n<tr>\n<td width=\"112\">util<\/td>\n<td width=\"521\">util module includes utility functions useful for programmers.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3>Loading Core Modules<\/h3>\n<p>In order to use Node.js core or NPM modules, import it using require() function as<\/p>\n<p>var module = require(&#8216;module_name&#8217;);<\/p>\n<p>As per above syntax, specify the module name in the require() function. The require() function will return an object, function, property or any other JavaScript type, depending on what the specified module returns.<\/p>\n<p>The following example demonstrates how to use Node.js http module to create a web server.<\/p>\n<p>Example: Load and Use Core http Module<\/p>\n<p>var http = require(&#8216;http&#8217;);<\/p>\n<p>var server = http.createServer(function(req, res){<\/p>\n<p>\/\/write code here<\/p>\n<p>});<\/p>\n<p>server.listen(5000);<\/p>\n<p>In the above example, require() function returns an object because http module returns its functionality as an object, you can then use its properties and methods using dot notation e.g. http.createServer(). In this way, you can load and use Node.js core modules in your application.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Node.js has several modules compiled into the binary. The core modules are defined within Node.js&#8217;s source and are located in the lib\/ folder. Core modules are always preferentially loaded if their identifier is passed to require(). For instance, require(&#8216;http&#8217;) will always return the built in HTTP module, even if there is a file by that&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"categories":[8453],"tags":[8477],"class_list":["post-72660","page","type-page","status-publish","hentry","category-node-js","tag-core-modules"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Core Modules - Tutorial<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.vskills.in\/certification\/tutorial\/core-modules\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Core Modules - Tutorial\" \/>\n<meta property=\"og:description\" content=\"Node.js has several modules compiled into the binary. The core modules are defined within Node.js&#8217;s source and are located in the lib\/ folder. Core modules are always preferentially loaded if their identifier is passed to require(). For instance, require(&#8216;http&#8217;) will always return the built in HTTP module, even if there is a file by that...\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.vskills.in\/certification\/tutorial\/core-modules\/\" \/>\n<meta property=\"og:site_name\" content=\"Tutorial\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/vskills.in\/\" \/>\n<meta property=\"article:modified_time\" content=\"2024-04-12T08:52:58+00:00\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/core-modules\/\",\"url\":\"https:\/\/www.vskills.in\/certification\/tutorial\/core-modules\/\",\"name\":\"Core Modules - Tutorial\",\"isPartOf\":{\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/#website\"},\"datePublished\":\"2020-01-14T11:05:21+00:00\",\"dateModified\":\"2024-04-12T08:52:58+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/core-modules\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.vskills.in\/certification\/tutorial\/core-modules\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/core-modules\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.vskills.in\/certification\/tutorial\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Core Modules\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/#website\",\"url\":\"https:\/\/www.vskills.in\/certification\/tutorial\/\",\"name\":\"Tutorial\",\"description\":\"Vskills - A initiative in elearning and certification\",\"publisher\":{\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.vskills.in\/certification\/tutorial\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/#organization\",\"name\":\"Vskills\",\"url\":\"https:\/\/www.vskills.in\/certification\/tutorial\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.vskills.in\/certification\/tutorial\/wp-content\/uploads\/2017\/07\/vskills-min-logo.jpg\",\"contentUrl\":\"https:\/\/www.vskills.in\/certification\/tutorial\/wp-content\/uploads\/2017\/07\/vskills-min-logo.jpg\",\"width\":73,\"height\":55,\"caption\":\"Vskills\"},\"image\":{\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/vskills.in\/\",\"https:\/\/x.com\/vskills_in\",\"https:\/\/www.linkedin.com\/company-beta\/1371554\/\",\"https:\/\/www.youtube.com\/channel\/UCMWnscxPwRF_PqXo9B7q_Tw\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Core Modules - Tutorial","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:\/\/www.vskills.in\/certification\/tutorial\/core-modules\/","og_locale":"en_US","og_type":"article","og_title":"Core Modules - Tutorial","og_description":"Node.js has several modules compiled into the binary. The core modules are defined within Node.js&#8217;s source and are located in the lib\/ folder. Core modules are always preferentially loaded if their identifier is passed to require(). For instance, require(&#8216;http&#8217;) will always return the built in HTTP module, even if there is a file by that...","og_url":"https:\/\/www.vskills.in\/certification\/tutorial\/core-modules\/","og_site_name":"Tutorial","article_publisher":"https:\/\/www.facebook.com\/vskills.in\/","article_modified_time":"2024-04-12T08:52:58+00:00","twitter_misc":{"Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.vskills.in\/certification\/tutorial\/core-modules\/","url":"https:\/\/www.vskills.in\/certification\/tutorial\/core-modules\/","name":"Core Modules - Tutorial","isPartOf":{"@id":"https:\/\/www.vskills.in\/certification\/tutorial\/#website"},"datePublished":"2020-01-14T11:05:21+00:00","dateModified":"2024-04-12T08:52:58+00:00","breadcrumb":{"@id":"https:\/\/www.vskills.in\/certification\/tutorial\/core-modules\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.vskills.in\/certification\/tutorial\/core-modules\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.vskills.in\/certification\/tutorial\/core-modules\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.vskills.in\/certification\/tutorial\/"},{"@type":"ListItem","position":2,"name":"Core Modules"}]},{"@type":"WebSite","@id":"https:\/\/www.vskills.in\/certification\/tutorial\/#website","url":"https:\/\/www.vskills.in\/certification\/tutorial\/","name":"Tutorial","description":"Vskills - A initiative in elearning and certification","publisher":{"@id":"https:\/\/www.vskills.in\/certification\/tutorial\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.vskills.in\/certification\/tutorial\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.vskills.in\/certification\/tutorial\/#organization","name":"Vskills","url":"https:\/\/www.vskills.in\/certification\/tutorial\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.vskills.in\/certification\/tutorial\/#\/schema\/logo\/image\/","url":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-content\/uploads\/2017\/07\/vskills-min-logo.jpg","contentUrl":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-content\/uploads\/2017\/07\/vskills-min-logo.jpg","width":73,"height":55,"caption":"Vskills"},"image":{"@id":"https:\/\/www.vskills.in\/certification\/tutorial\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/vskills.in\/","https:\/\/x.com\/vskills_in","https:\/\/www.linkedin.com\/company-beta\/1371554\/","https:\/\/www.youtube.com\/channel\/UCMWnscxPwRF_PqXo9B7q_Tw"]}]}},"_links":{"self":[{"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/pages\/72660","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/comments?post=72660"}],"version-history":[{"count":3,"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/pages\/72660\/revisions"}],"predecessor-version":[{"id":73170,"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/pages\/72660\/revisions\/73170"}],"wp:attachment":[{"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/media?parent=72660"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/categories?post=72660"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/tags?post=72660"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}