The CreatorCon Call for Content is officially open! Get started here.

Getting Build Failed Error when trying to build react project

prasanna-ph
Tera Contributor

Hi,

I followed below article and created a react project using ServiceNow SDK but when I am trying to build the project using npm run build I am getting error shown in the attached screenshot, do anyone have any idea about why I am getting this error?

C:\SN_DSK> npm run build

> react-ui-page-ts-sample@0.0.1 build
> now-sdk build

[now-sdk] Initiating the build process ...
[now-sdk] Building project from C:\SN_DSK...
[now-sdk] Running script "prebuild" from C:/SN_DSK/now.prebuild.mjs
[now-sdk] ERROR: Build failed: Only URLs with a scheme in: file, data, and node are supported by the default ESM loader. On Windows, absolute paths must be valid file:// URLs. Received protocol 'c:'

Node version : v20.18.0
Npm : 8.19.3

 

User interface development with React 

1 ACCEPTED SOLUTION

BryceG
ServiceNow Employee
ServiceNow Employee

Hi @prasanna-ph looks like you ran into a know bug we have with Windows.  The 4.0.1 version should resolve this for you, and we are hoping to publish that today so keep an eye out.

View solution in original post

3 REPLIES 3

M Iftikhar
Giga Sage

Hi @prasanna-ph,

The error isn’t about your code specifically.It’s coming from how Node handles Windows paths in the ServiceNow SDK build process. 

Things to check/try: 

  • Make sure you’re on the latest @servicenow/sdk. 
  • Delete node_modules and package-lock.json, then run npm install again. 
  • The error Received protocol 'c:' usually means an import path is being treated as a URL. Check now.prebuild.mjs (or its dependencies) for absolute paths like C:/.... They need to be formatted as file:///C:/... for Node’s ESM loader. 
  • If you keep hitting this on native Windows, running the project from WSL (Linux subsystem) avoids the Windows C:/ path issue entirely. 

Most people have resolved this either by updating to the latest SDK or by correcting the Windows file path handling. 

Thanks & Regards,  
Muhammad Iftikhar  

If my response helped, please mark it as the accepted solution so others can benefit as well. 

BryceG
ServiceNow Employee
ServiceNow Employee

Hi @prasanna-ph looks like you ran into a know bug we have with Windows.  The 4.0.1 version should resolve this for you, and we are hoping to publish that today so keep an eye out.

prasanna-ph
Tera Contributor

Hi @BryceG,

Thank you, Updating to 4.0.1 solved my issue.