{"id":399589,"date":"2023-09-14T14:27:17","date_gmt":"2023-09-14T14:27:17","guid":{"rendered":"https:\/\/webkul.com\/blog\/?p=399589"},"modified":"2023-09-19T06:22:26","modified_gmt":"2023-09-19T06:22:26","slug":"usage-of-node-js-in-magento2","status":"publish","type":"post","link":"https:\/\/webkul.com\/blog\/usage-of-node-js-in-magento2\/","title":{"rendered":"Usage of node js in Magento 2"},"content":{"rendered":"\n<p>Here&#8217;s a general overview of how you can use Node js with Magento 2.<\/p>\n\n\n\n<p><strong>Installing <a href=\"https:\/\/nodejs.org\/en\">Node js<\/a>: &#8211;<\/strong> First, Make sure Node is already installed on your server.<\/p>\n\n\n\n<p>If not, visit this blog to install the node &#8211; <a href=\"https:\/\/webkul.com\/blog\/installing-node-using-nvm\/\">Installing node using nvm<\/a><\/p>\n\n\n\n<p><strong>Install Dependencies:<\/strong>&#8211; Depending on the specific task you want to achieve, you might need to install various Node js packages using npm (Node Package Manager).<\/p>\n\n\n\n<p>Use <strong><code>npm install<\/code> package-name<\/strong> to install required dependencies at your Magento root. <\/p>\n\n\n\n<p>Example:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">npm install express\nnpm install multer<\/pre>\n\n\n\n<p>After installing the node packages via the npm a file named package.json will be created at the root and it looks like as below &#8211;<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">{\n  &quot;dependencies&quot;: {\n    &quot;express&quot;: &quot;^4.18.2&quot;,\n    &quot;multer&quot;: &quot;^1.4.5-lts.1&quot;,\n  }\n}<\/pre>\n\n\n\n<p><strong>Create Node js API<\/strong>:- Depending on the specific need create your node js API and place this file in the Magento root directory.<\/p>\n\n\n\n<p>So let us create a basic node API named server.js<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">const express = require(&#039;express&#039;);\nconst app = express();\n\napp.get(&#039;\/api\/data&#039;, (request, response) =&gt; {\n  response.json({ message: &#039;Node js with Magento 2&#039; });\n});\n\nconst port = 8080;\napp.listen(port, () =&gt; {\n  console.log(`Server is running on port ${port}`);\n});<\/pre>\n\n\n\n<p><strong>Note:-<\/strong> You can set the port dynamic by adding a field in the configuration (system.xml).<\/p>\n\n\n\n<p><strong>Running Your Node js API<\/strong>:- At Magento 2 root run the below command to run the node server.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">node server.js<\/pre>\n\n\n\n<p><strong>Note:-<\/strong> You can also run the node server dynamically by creating a button (start and stop) in the Magento 2 configuration. <\/p>\n\n\n\n<p>\u2022 When hit the button to start the node server you can use the below code.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">&lt;?php\n\nnamespace Webkul\\NodeWithMagento\\Controller\\Adminhtml;\n\nclass Start extends \\Magento\\Backend\\App\\Action\n{\n    \/**\n     * Api Url\n     *\/\n    public const API_URL = &quot;server.js&quot;;\n\n    \/**\n     * @var \\Magento\\Framework\\Controller\\Result\\JsonFactory\n     *\/\n    protected $resultJsonFactory;\n\n    \/**\n     * @var \\Magento\\Framework\\App\\Filesystem\\DirectoryList\n     *\/\n    protected $directoryList;\n\n    \/**\n     * @var \\Magento\\Framework\\Shell\n     *\/\n    protected $shell;\n\n    \/**\n     * @param \\Magento\\Backend\\App\\Action\\Context $context\n     * @param \\Magento\\Framework\\Controller\\Result\\JsonFactory $resultJsonFactory\n     * @param \\Magento\\Framework\\App\\Filesystem\\DirectoryList $directoryList\n     * @param \\Magento\\Framework\\Shell $shell\n     *\/\n    public function __construct(\n        \\Magento\\Backend\\App\\Action\\Context $context,\n        \\Magento\\Framework\\Controller\\Result\\JsonFactory $resultJsonFactory,\n        \\Magento\\Framework\\App\\Filesystem\\DirectoryList $directoryList,\n        \\Magento\\Framework\\Shell $shell\n    ) {\n        parent::__construct($context);\n        $this-&gt;resultJsonFactory = $resultJsonFactory;\n        $this-&gt;directoryList = $directoryList;\n        $this-&gt;shell = $shell;\n    }\n\n    \/**\n     * Execute method to start server\n     *\n     * @return \\Magento\\Framework\\Controller\\Result\\Json\n     *\/\n    public function execute()\n    {\n        $response = new \\Magento\\Framework\\DataObject();\n        $response-&gt;setError(false);\n        $data = $this-&gt;getRequest()-&gt;getParams();\n        $response-&gt;setRoot($this-&gt;directoryList-&gt;getRoot());\n        $rootPath = $this-&gt;directoryList-&gt;getRoot();\n        $node = $this-&gt;shell-&gt;execute(&#039;whereis node&#039;);\n        $nodePath = explode(&#039; &#039;, $node);\n\n        if (!isset($nodePath&#091;1]) || $nodePath&#091;1] == &#039;&#039;) {\n            $node = $this-&gt;shell-&gt;execute(&#039;whereis nodejs&#039;);\n            $nodePath = explode(&#039; &#039;, $node);\n        }\n        if (count($nodePath)) {\n            $this-&gt;shell-&gt;execute($nodePath&#091;1].&#039; &#039;.$rootPath.&#039;\/&#039; . (self::API_URL) . &quot; &gt; \/dev\/null &amp;&quot;);\n            $response-&gt;setMessage(__(&#039;Server Started.&#039;));\n            $this-&gt;messageManager-&gt;addSuccess(__(&#039;Server has been started.&#039;));\n        } else {\n            $response-&gt;setError(true);\n            $response-&gt;addMessage(__(&#039;NodeJs Api Path not found.&#039;));\n            $this-&gt;messageManager-&gt;setError(__(&#039;NodeJs Api Path not found.&#039;));\n        }\n\n        return $this-&gt;resultJsonFactory-&gt;create()-&gt;setJsonData($response-&gt;toJson());\n    }\n}<\/pre>\n\n\n\n<p>In the above code<code><strong>'whereis node<\/strong>'<\/code> is a shell command that is used to locate the executable file for the Node js runtime in the system.<\/p>\n\n\n\n<p>\u2022 When hit the button to stop the node server you can use the below code.-<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">&lt;?php\n\nnamespace Webkul\\NodeWithMagento\\Controller\\Adminhtml;\n\nclass Stop extends \\Magento\\Backend\\App\\Action\n{\n    \/**\n     * @var \\Magento\\Framework\\Controller\\Result\\JsonFactory\n     *\/\n    protected $resultJsonFactory;\n\n    \/**\n     * @var \\Magento\\Framework\\Shell\n     *\/\n    protected $shell;\n\n    \/**\n     * @param \\Magento\\Backend\\App\\Action\\Context $context\n     * @param \\Magento\\Framework\\View\\Result\\PageFactory $resultPageFactory\n     * @param \\Magento\\Framework\\Controller\\Result\\JsonFactory $resultJsonFactory\n     * @param \\Magento\\Framework\\Shell $shell\n     *\/\n    public function __construct(\n        \\Magento\\Backend\\App\\Action\\Context $context,\n        \\Magento\\Framework\\View\\Result\\PageFactory $resultPageFactory,\n        \\Magento\\Framework\\Controller\\Result\\JsonFactory $resultJsonFactory,\n        \\Magento\\Framework\\Shell $shell\n    ) {\n        parent::__construct($context);\n        $this-&gt;resultJsonFactory = $resultJsonFactory;\n        $this-&gt;shell = $shell;\n    }\n   \n    \/**\n     * Execute method to stop server\n     *\n     * @return \\Magento\\Framework\\Controller\\Result\\Json\n     *\/\n    public function execute()\n    {\n        $response = new \\Magento\\Framework\\DataObject();\n        $response-&gt;setError(false);\n        $data = $this-&gt;getRequest()-&gt;getParams();\n        $getUserPath = $this-&gt;shell-&gt;execute(&#039;whereis fuser&#039;);\n       \n        if ($getUserPath) {\n            $getUserPath = explode(&#039; &#039;, $getUserPath);\n            if (isset($getUserPath&#091;1])) {\n                $stopServer = $this-&gt;shell-&gt;execute($getUserPath&#091;1].&#039; -k &#039;.$data&#091;&#039;port&#039;].&#039;\/tcp&#039;);\n                $this-&gt;messageManager-&gt;addSuccess(__(&#039;Server has been stopped.&#039;));\n            }\n        } else {\n            $response-&gt;setError(true);\n            $response-&gt;setMessage(__(&#039;Something went wrong.&#039;));\n            $this-&gt;messageManager-&gt;addError(__(&#039;Something went wrong.&#039;));\n        }\n        return $this-&gt;resultJsonFactory-&gt;create()-&gt;setJsonData($response-&gt;toJson());\n    }\n}<\/pre>\n\n\n\n<p>In the above code <strong>fuser<\/strong> can identify the process using the files or sockets. And fuser can be also used to kill the process. So by using <code>whereis fuser<\/code> you can stop the server.<\/p>\n\n\n\n<p><strong>Call Node js API in Magento 2:-<\/strong> Based on your need call node <a href=\"https:\/\/webkul.com\/blog\/magento2-custom-rest-api\/\">API in Magento 2<\/a> file such as in controllers, plugins, etc. via curl.<\/p>\n\n\n\n<p>As I have created a node API server.js above so I&#8217;m calling it in my controller.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">&lt;?php\n\nnamespace Webkul\\NodeWithMagento\\Controller\\Index;\n\nuse Magento\\Framework\\App\\Action\\Action;\nuse Magento\\Framework\\App\\Action\\Context;\n\nclass Index extends Action\n{\n    \/**\n     * @var \\Magento\\Framework\\Json\\Helper\\Data\n     *\/\n    protected $jsonHelper;\n\n    \/**\n     * @var \\Magento\\Framework\\Controller\\Result\\JsonFactory\n     *\/\n    protected $resultJsonFactory;\n\n    \/**\n     * @var \\Magento\\Framework\\HTTP\\Client\\Curl\n     *\/\n    protected $curl;\n\n    public function __construct(\n        Context $context,\n        \\Magento\\Framework\\Json\\Helper\\Data $jsonHelper,\n        \\Magento\\Framework\\Controller\\Result\\JsonFactory $resultJsonFactory,\n        \\Magento\\Framework\\HTTP\\Client\\Curl $curl\n    ) {\n        parent::__construct($context);\n        $this-&gt;jsonHelper = $jsonHelper;\n        $this-&gt;resultJsonFactory = $resultJsonFactory;\n        $this-&gt;curl = $curl;\n    }\n\n    public function execute()\n    {\n        $apiUrl = &#039;http:\/\/localhost:3000\/api\/data&#039;;\n        $this-&gt;curl-&gt;get($apiUrl);\n        $response = $this-&gt;curl-&gt;getBody();\n        $data = $this-&gt;jsonHelper-&gt;jsonDecode($response, true);\n        \n        \/\/ Return the API response as JSON\n        $result = $this-&gt;resultJsonFactory-&gt;create();\n        return $result-&gt;setData($data);\n    }\n}<\/pre>\n\n\n\n<p>That\u2019s all about of Basic usage of node js in Magento 2. Hope this will be helpful.<\/p>\n\n\n\n<p>Thanks for visiting the <a href=\"https:\/\/webkul.com\/\">Webkul<\/a> blog! \ud83d\ude42<\/p>\n\n\n\n<p>Happy Coding!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Here&#8217;s a general overview of how you can use Node js with Magento 2. Installing Node js: &#8211; First, Make sure Node is already installed on your server. If not, visit this blog to install the node &#8211; Installing node using nvm Install Dependencies:&#8211; Depending on the specific task you want to achieve, you might <a href=\"https:\/\/webkul.com\/blog\/usage-of-node-js-in-magento2\/\">[&#8230;]<\/a><\/p>\n","protected":false},"author":430,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[302],"tags":[14763,14762],"class_list":["post-399589","post","type-post","status-publish","format-standard","hentry","category-magento2","tag-basic-use-of-node-in-magento-2","tag-node-js-in-magento-2"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Usage of node js in Magento 2 - Webkul Blog<\/title>\n<meta name=\"description\" content=\"Usage of node js with magento2 basic usage of node js in magento 2 how to use node js in magento 2 craete a node api in magento 2\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/webkul.com\/blog\/usage-of-node-js-in-magento2\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Usage of node js in Magento 2 - Webkul Blog\" \/>\n<meta property=\"og:description\" content=\"Usage of node js with magento2 basic usage of node js in magento 2 how to use node js in magento 2 craete a node api in magento 2\" \/>\n<meta property=\"og:url\" content=\"https:\/\/webkul.com\/blog\/usage-of-node-js-in-magento2\/\" \/>\n<meta property=\"og:site_name\" content=\"Webkul Blog\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/webkul\/\" \/>\n<meta property=\"article:published_time\" content=\"2023-09-14T14:27:17+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-09-19T06:22:26+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-og.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"630\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Shweta Singh\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@webkul\" \/>\n<meta name=\"twitter:site\" content=\"@webkul\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Shweta Singh\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/webkul.com\/blog\/usage-of-node-js-in-magento2\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/webkul.com\/blog\/usage-of-node-js-in-magento2\/\"},\"author\":{\"name\":\"Shweta Singh\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/2aa9e6c8f634365b94451ac7a636a444\"},\"headline\":\"Usage of node js in Magento 2\",\"datePublished\":\"2023-09-14T14:27:17+00:00\",\"dateModified\":\"2023-09-19T06:22:26+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/webkul.com\/blog\/usage-of-node-js-in-magento2\/\"},\"wordCount\":355,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/webkul.com\/blog\/#organization\"},\"keywords\":[\"basic use of node in magento 2\",\"node js in magento 2\"],\"articleSection\":[\"Magento2\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/webkul.com\/blog\/usage-of-node-js-in-magento2\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/webkul.com\/blog\/usage-of-node-js-in-magento2\/\",\"url\":\"https:\/\/webkul.com\/blog\/usage-of-node-js-in-magento2\/\",\"name\":\"Usage of node js in Magento 2 - Webkul Blog\",\"isPartOf\":{\"@id\":\"https:\/\/webkul.com\/blog\/#website\"},\"datePublished\":\"2023-09-14T14:27:17+00:00\",\"dateModified\":\"2023-09-19T06:22:26+00:00\",\"description\":\"Usage of node js with magento2 basic usage of node js in magento 2 how to use node js in magento 2 craete a node api in magento 2\",\"breadcrumb\":{\"@id\":\"https:\/\/webkul.com\/blog\/usage-of-node-js-in-magento2\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/webkul.com\/blog\/usage-of-node-js-in-magento2\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/webkul.com\/blog\/usage-of-node-js-in-magento2\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/webkul.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Usage of node js in Magento 2\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/webkul.com\/blog\/#website\",\"url\":\"https:\/\/webkul.com\/blog\/\",\"name\":\"Webkul Blog\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/webkul.com\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/webkul.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/webkul.com\/blog\/#organization\",\"name\":\"WebKul Software Private Limited\",\"url\":\"https:\/\/webkul.com\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png\",\"contentUrl\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png\",\"width\":380,\"height\":380,\"caption\":\"WebKul Software Private Limited\"},\"image\":{\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/webkul\/\",\"https:\/\/x.com\/webkul\",\"https:\/\/www.instagram.com\/webkul\/\",\"https:\/\/www.linkedin.com\/company\/webkul\",\"https:\/\/www.youtube.com\/user\/webkul\/\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/2aa9e6c8f634365b94451ac7a636a444\",\"name\":\"Shweta Singh\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/51b8ea403cd7931cc8ef43d9b80e04e02143fd85bae4fe4ff866790408fb82d0?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Feva.png&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/51b8ea403cd7931cc8ef43d9b80e04e02143fd85bae4fe4ff866790408fb82d0?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Feva.png&r=g\",\"caption\":\"Shweta Singh\"},\"url\":\"https:\/\/webkul.com\/blog\/author\/shweta-singh342\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Usage of node js in Magento 2 - Webkul Blog","description":"Usage of node js with magento2 basic usage of node js in magento 2 how to use node js in magento 2 craete a node api in magento 2","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:\/\/webkul.com\/blog\/usage-of-node-js-in-magento2\/","og_locale":"en_US","og_type":"article","og_title":"Usage of node js in Magento 2 - Webkul Blog","og_description":"Usage of node js with magento2 basic usage of node js in magento 2 how to use node js in magento 2 craete a node api in magento 2","og_url":"https:\/\/webkul.com\/blog\/usage-of-node-js-in-magento2\/","og_site_name":"Webkul Blog","article_publisher":"https:\/\/www.facebook.com\/webkul\/","article_published_time":"2023-09-14T14:27:17+00:00","article_modified_time":"2023-09-19T06:22:26+00:00","og_image":[{"width":1200,"height":630,"url":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-og.png","type":"image\/png"}],"author":"Shweta Singh","twitter_card":"summary_large_image","twitter_creator":"@webkul","twitter_site":"@webkul","twitter_misc":{"Written by":"Shweta Singh","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/webkul.com\/blog\/usage-of-node-js-in-magento2\/#article","isPartOf":{"@id":"https:\/\/webkul.com\/blog\/usage-of-node-js-in-magento2\/"},"author":{"name":"Shweta Singh","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/2aa9e6c8f634365b94451ac7a636a444"},"headline":"Usage of node js in Magento 2","datePublished":"2023-09-14T14:27:17+00:00","dateModified":"2023-09-19T06:22:26+00:00","mainEntityOfPage":{"@id":"https:\/\/webkul.com\/blog\/usage-of-node-js-in-magento2\/"},"wordCount":355,"commentCount":0,"publisher":{"@id":"https:\/\/webkul.com\/blog\/#organization"},"keywords":["basic use of node in magento 2","node js in magento 2"],"articleSection":["Magento2"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/webkul.com\/blog\/usage-of-node-js-in-magento2\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/webkul.com\/blog\/usage-of-node-js-in-magento2\/","url":"https:\/\/webkul.com\/blog\/usage-of-node-js-in-magento2\/","name":"Usage of node js in Magento 2 - Webkul Blog","isPartOf":{"@id":"https:\/\/webkul.com\/blog\/#website"},"datePublished":"2023-09-14T14:27:17+00:00","dateModified":"2023-09-19T06:22:26+00:00","description":"Usage of node js with magento2 basic usage of node js in magento 2 how to use node js in magento 2 craete a node api in magento 2","breadcrumb":{"@id":"https:\/\/webkul.com\/blog\/usage-of-node-js-in-magento2\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/webkul.com\/blog\/usage-of-node-js-in-magento2\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/webkul.com\/blog\/usage-of-node-js-in-magento2\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/webkul.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Usage of node js in Magento 2"}]},{"@type":"WebSite","@id":"https:\/\/webkul.com\/blog\/#website","url":"https:\/\/webkul.com\/blog\/","name":"Webkul Blog","description":"","publisher":{"@id":"https:\/\/webkul.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/webkul.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/webkul.com\/blog\/#organization","name":"WebKul Software Private Limited","url":"https:\/\/webkul.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png","contentUrl":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png","width":380,"height":380,"caption":"WebKul Software Private Limited"},"image":{"@id":"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/webkul\/","https:\/\/x.com\/webkul","https:\/\/www.instagram.com\/webkul\/","https:\/\/www.linkedin.com\/company\/webkul","https:\/\/www.youtube.com\/user\/webkul\/"]},{"@type":"Person","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/2aa9e6c8f634365b94451ac7a636a444","name":"Shweta Singh","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/51b8ea403cd7931cc8ef43d9b80e04e02143fd85bae4fe4ff866790408fb82d0?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Feva.png&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/51b8ea403cd7931cc8ef43d9b80e04e02143fd85bae4fe4ff866790408fb82d0?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Feva.png&r=g","caption":"Shweta Singh"},"url":"https:\/\/webkul.com\/blog\/author\/shweta-singh342\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/399589","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/users\/430"}],"replies":[{"embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/comments?post=399589"}],"version-history":[{"count":27,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/399589\/revisions"}],"predecessor-version":[{"id":401052,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/399589\/revisions\/401052"}],"wp:attachment":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/media?parent=399589"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/categories?post=399589"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/tags?post=399589"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}