Deploy failed with "URL is not defined"

I tried to deploy my project to the “staging” environment I setup in moovweb.app and during the deploy process, I received the following error:

xdn-default-template git:(master) npm run deploy -- --environment=staging

> xdn-default-template@ deploy /Users/tristanlee/Projects/xdn-default-template
> xdn deploy "--environment=staging"

🔑 Authenticated as xxx@gmail.com on https://moovweb.app

📋 Deploying to:
> team=Private space
> site=xdn-default-template
> branch=master
> environment=staging
> xdn-version=2.6.4
> commit-url=https://github.com/xxx/xdn-default-template/commit/a5151dad363ed719c69eda07a161c6dc1215fe61

⌛ Initializing build
> build=7
> Since this is the first deployment to the staging environment, it will take longer than subsequent deployments.
done (26805ms)
🛠️ Building your app for deployment on the MOOVWEB XDN

> Bundling ./src/routes.ts and xdn.config.js... done.
Error: Project build failed: URL is not defined
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! xdn-default-template@ deploy: `xdn deploy "--environment=staging"`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the xdn-default-template@ deploy script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/tristanlee/.npm/_logs/2020-09-15T15_23_54_685Z-debug.log

What URL is this error message referring to?

Hmm… I don’t think that’s anything specific to the XDN. Could it be that you’re referencing the URL class somewhere in your router without requiring it?

Could you post your router here?

The issue ended up being Node switched from 12.x to 8.x. Node 12 is the required version for the build.

1 Like