Node.js docs (#2019)
* Updated content in various nodes in NodeJS -Why nodejs, Installing NodeJS , CommonJS vs ESM , Global keyword,npm workspaces , creating packages , __dirname , __filename Updated various sub groups with information in NODEJS * Update content/roadmaps/107-nodejs/content/100-nodejs-introduction/101-why-nodejs.md * Update content/roadmaps/107-nodejs/content/100-nodejs-introduction/101-why-nodejs.md * Update content/roadmaps/107-nodejs/content/100-nodejs-introduction/104-running-nodejs-code.md * Update content/roadmaps/107-nodejs/content/100-nodejs-introduction/101-why-nodejs.md * Update content/roadmaps/107-nodejs/content/101-nodejs-modules/100-commonjs-vs-esm.md * Update content/roadmaps/107-nodejs/content/101-nodejs-modules/102-global-keyword.md * Update content/roadmaps/107-nodejs/content/100-nodejs-introduction/101-why-nodejs.md * Update content/roadmaps/107-nodejs/content/100-nodejs-introduction/101-why-nodejs.md * Update 101-why-nodejs.md * Update content/roadmaps/107-nodejs/content/102-nodejs-npm/105-npm-workspaces.md * Update content/roadmaps/107-nodejs/content/102-nodejs-npm/106-creating-packages.md * Update content/roadmaps/107-nodejs/content/105-nodejs-working-with-files/107-dirname.md * Update content/roadmaps/107-nodejs/content/105-nodejs-working-with-files/108-filename.md Co-authored-by: Kamran Ahmed <kamranahmed.se@gmail.com>pull/2023/head
parent
300b6dd1e7
commit
7458c55788
8 changed files with 60 additions and 8 deletions
@ -1 +1,13 @@ |
|||||||
# Why nodejs |
# Why Node.js |
||||||
|
|
||||||
|
* Node.js is OpenSource |
||||||
|
* Guarantees ease of scaling applications vertically by adding new resources to the existing node and horizontally with the addition of new nodes |
||||||
|
* It facilitates building separate components that easily complement larger applications, which means saving money at the initial development stages and potentially shortening time-to-market, reusable code (some of the code can be used both on the front and backend) |
||||||
|
* Tested on production (a lot of [companies use it](https://selleo.com/blog/10-successful-companies-using-nodejs) from the very beginning in 2009) |
||||||
|
* offers improved performance thanks to Chrome’s V8 engine |
||||||
|
* using JavaScript on both backend and frontend makes Node a great choice to improve speed and simplicity of implementation |
||||||
|
|
||||||
|
<ResourceGroupTitle>Free Content</ResourceGroupTitle> |
||||||
|
<BadgeLink colorScheme='yellow' badgeText='Read' href='https://nodejs.dev/en/learn/'>Learn Node.js</BadgeLink> |
||||||
|
<BadgeLink colorScheme='yellow' badgeText='Read' href='https://medium.com/selleo/why-choose-node-js-b0091ad6c3fc'>Why Choose Node.js?</BadgeLink> |
||||||
|
<BadgeLink colorScheme='yellow' badgeText='Read' href='https://www.bitovi.com/blog/5-reasons-to-choose-nodejs'>5 Reasons to Choose Node.js</BadgeLink> |
||||||
|
@ -1 +1,6 @@ |
|||||||
# Running nodejs code |
# Running Node.js Code |
||||||
|
|
||||||
|
The usual way to run a Node.js program is to run the globally available `node` command (once you install Node.js) and pass the name of the file you want to execute. |
||||||
|
|
||||||
|
<ResourceGroupTitle>Free Content</ResourceGroupTitle> |
||||||
|
<BadgeLink colorScheme='yellow' badgeText='Read' href='https://nodejs.dev/en/learn/run-nodejs-scripts-from-the-command-line/'>Run Node.js from Command Line</BadgeLink> |
@ -1 +1,8 @@ |
|||||||
# Commonjs vs esm |
# CommonJS vs ESM |
||||||
|
|
||||||
|
The CommonJS module system, on the other hand, is built into Node.js. Before the introduction of the ES module in Node.js, CommonJS was the standard for Node.js modules. As a result, many Node.js libraries and modules are written with CommonJS. |
||||||
|
|
||||||
|
The ES module format was created to standardize the JavaScript module system. It has become the standard format for encapsulating JavaScript code for reuse. |
||||||
|
|
||||||
|
<ResourceGroupTitle>Free Content</ResourceGroupTitle> |
||||||
|
<BadgeLink colorScheme='yellow' badgeText='Read' href='https://reflectoring.io/nodejs-modules-imports/'>CommonJS vs ESM</BadgeLink> |
@ -1 +1,6 @@ |
|||||||
# Global keyword |
# global Keyword |
||||||
|
|
||||||
|
In browsers, the top-level scope is the global scope. This means that within the browser var something will define a new global variable. In Node.js this is different. The top-level scope is not the global scope; `var something` inside a Node.js module will be local to that module. |
||||||
|
|
||||||
|
<ResourceGroupTitle>Free Content</ResourceGroupTitle> |
||||||
|
<BadgeLink colorScheme='yellow' badgeText='Read' href='https://nodejs.org/api/globals.html#global'>global Keyword in Node.js</BadgeLink> |
@ -1 +1,7 @@ |
|||||||
# Npm workspaces |
# npm workspaces |
||||||
|
|
||||||
|
Workspace is a generic term that refers to the set of npm CLI features that support managing multiple packages from your local file system from within a singular top-level root package. |
||||||
|
|
||||||
|
<ResourceGroupTitle>Free Content</ResourceGroupTitle> |
||||||
|
<BadgeLink colorScheme='blue' badgeText='Official Docs' href='https://docs.npmjs.com/cli/v8/using-npm/workspaces'>npm workspaces</BadgeLink> |
||||||
|
<BadgeLink colorScheme='yellow' badgeText='Read' href='https://ruanmartinelli.com/posts/npm-7-workspaces-1'>Getting Started with Npm Workspaces </BadgeLink> |
||||||
|
@ -1 +1,7 @@ |
|||||||
# Creating packages |
# Creating Packages |
||||||
|
|
||||||
|
npm packages allow you to bundle some specific functionality into a reusable package which can then be uploaded to some package registry such as npm or GitHub packages and then be installed and reused in projects using npm. |
||||||
|
|
||||||
|
<ResourceGroupTitle>Free Content</ResourceGroupTitle> |
||||||
|
<BadgeLink colorScheme='yellow' badgeText='Read' href='https://www.freecodecamp.org/news/how-to-make-a-beautiful-tiny-npm-package-and-publish-it-2881d4307f78/'>How to make a tiny npm package and publish it</BadgeLink> |
||||||
|
<BadgeLink colorScheme='yellow' badgeText='Read' href='https://snyk.io/blog/best-practices-create-modern-npm-package/'>Best practices for creating a modern npm package</BadgeLink> |
@ -1 +1,7 @@ |
|||||||
# Dirname |
# __dirname |
||||||
|
|
||||||
|
The `__dirname` in a node script returns the path of the folder where the current JavaScript file resides. `__filename` and `__dirname` are used to get the filename and directory name of the currently executing file. |
||||||
|
|
||||||
|
<ResourceGroupTitle>Free Content</ResourceGroupTitle> |
||||||
|
<BadgeLink colorScheme='blue' badgeText='Official Docs' href='https://nodejs.org/docs/latest/api/modules.html#__dirname'>Official Website</BadgeLink> |
||||||
|
<BadgeLink colorScheme='yellow' badgeText='Read' href='https://www.digitalocean.com/community/tutorials/nodejs-how-to-use__dirname'>How to use __dirname</BadgeLink> |
@ -1 +1,6 @@ |
|||||||
# Filename |
# __filename |
||||||
|
|
||||||
|
The `__filename` in Node.js returns the filename of the executed code. It gives the absolute path of the code file. The following approach covers implementing `__filename` in the Node.js project. |
||||||
|
|
||||||
|
<ResourceGroupTitle>Free Content</ResourceGroupTitle> |
||||||
|
<BadgeLink colorScheme='blue' badgeText='Official Docs' href='https://nodejs.org/docs/latest/api/modules.html#__filename'>Official Docs</BadgeLink> |
Loading…
Reference in new issue