How to solve “404-cannot find module” error on Node.js V12

By | October 28, 2021

Node.js is an open source, cross-platform runtime environment for server-side and networking applications. Node.js applications are written in JavaScript, and can be run within the Node.js runtime on OSX, Microsoft Windows, Linux.

Node.js on Sage X3:

We come across scenario where x3 require integration with Node.js. It increases the efficiency of the development process as it fills the gap between frontend and backend applications.NodeJS module can be created by copying the JS code to the Syracuse folder that stores the modules.

Node. Js is faster because it is asynchronous and single-threaded. This means that all I/O operations don’t block any other operations.JavaScript code is also executed in the process main thread while all other I/O operations are executed in separate threads which results in almost no delays.

Error:404 cannot find module:

This blog helps in rectifying status code :404 cannot find module ‘syracuse-httpclient/lib/httpClient’ error, while executing Node.js through X3.

Status Code 404:

A 404-error message is a Hypertext Transfer Protocol (HTTP) status code indicating the server could not find the requested website. In other words, web browser can connect with the server, but the specific page we are trying to access can’t be reached.

Or the file or page that the browser is requesting wasn’t found on the server.

Sage x3, Node.js, Gumu file starts with the header as mentioned on below Fig 02

On V11, To identity the httpclient we can declare

var httpClient =require(“syracuse-httpclient/lib/httpClient”);

Solution for above error:

but in V12 we have to declare

var httpClient = require(“@sage/syracuse-lib/src/http-client/httpClient”);

Function calls the web service with httpClient.httpRequest. Then it checks the status code and parses the reply with jsxml. parse. It then extracts the result byBody.

This blog helps us in understanding integration of Node.js with X3 and solving status code: 404-cannot find module on syracuse-httpclient/lib/httpClient’ node.js on V12.