0

I have node.js 18.16.0 running on my machine. Configured a new nx workspace with react and later added express. When I serve the react app, it builds fine and launches the app but attempting to serve the express app, the following error is logged:

Error: Only URLs with a scheme in: file and data are supported by the default ESM loader. On Windows, absolute paths must be valid file:// URLs. Received protocol 'c:'
at new NodeError (node:internal/errors:399:5)
at throwIfUnsupportedURLScheme (node:internal/modules/esm/resolve:1059:11)
at defaultResolve (node:internal/modules/esm/resolve:1135:3)
at nextResolve (node:internal/modules/esm/loader:163:28)
at ESMLoader.resolve (node:internal/modules/esm/loader:838:30)
at ESMLoader.getModuleJob (node:internal/modules/esm/loader:424:18)
at ESMLoader.import (node:internal/modules/esm/loader:525:22)
at importModuleDynamically (node:internal/modules/cjs/loader:1186:29)
at importModuleDynamicallyWrapper (node:internal/vm/module:429:21)
at importModuleDynamically (node:internal/vm:106:46)

This may be related to webpack and the way nx configures webpack. Spent countless hours to try resolve it but no luck.

Any alternatives or workaround for this?

@nx/express@16.1.4 @nx/webpack@16.1.4

Chief
  • 854
  • 12
  • 27
  • Found a solution here: https://stackoverflow.com/a/76236275/4996792 Downgrade to nx packages to 16.1.0 – Chief May 15 '23 at 22:44

1 Answers1

0

I had the same issue - I was using @nrwl/workspace@15.9.2 with @nx/express@16

I installed @nrwl/express@15.9.2 instead and it's working now

tom
  • 1
  • 1