Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

znv use of 'colorette' breaks Vercel and CloudFlare deployments #14

Closed
appurist opened this issue Dec 14, 2023 · 3 comments
Closed

znv use of 'colorette' breaks Vercel and CloudFlare deployments #14

appurist opened this issue Dec 14, 2023 · 3 comments

Comments

@appurist
Copy link

I built a fairly simple solid-start app (although probably any SSR app such as Next.js would also suffer this problem), and added znv, and while the resulting vite dev environment runs it fine, deployment to either Vercel or CloudFlare Pages fails with the server function unable to import module tty.

For example, with Vercel:

> vercel --yes --prod

Vercel CLI 32.7.2
🔍  Inspect: https://vercel.com/appurist/market/3bS4bgYzUUec8N7LtvpSxHF1V4qW [3s]
✅  Production: https://market-eq1iht44q-appurist.vercel.app [3s]
Error: The Edge Function "render" is referencing unsupported modules:
        - vercel/path0/dist/index.mjs: tty

CloudFlare deploy is more descriptive:

01:21:10.817    ✘ [ERROR] Could not resolve "tty"
01:21:10.818    
01:21:10.818        [[path]].js:1:21:
01:21:10.818          1 │ import * as tty from 'tty';
01:21:10.818            ╵                      ~~~~~
01:21:10.818    
01:21:10.818      The package "tty" wasn't found on the file system but is built into node.
01:21:10.819      Add the "nodejs_compat" compatibility flag to your Pages project to enable Node.js compatibility.

However adding nodejs_compat or changing the import to 'node:tty' did not help.

Perhaps the import of colorette (or tty) in znv can be eliminated, or at least more optional, e.g. with a dynamic require('node:tty') and a conditional check before use (rather than import failing immediately). The usage in question is this line:

const isCompatibleTerminal =
  tty && tty.isatty && tty.isatty(1) && env.TERM && !isDumbTerminal;

I believe this is in colorette so znv usage is indirect. However, I need to ask why an environment parsing library needs colorized console output? Perhaps that can just be dropped. My workaround was to eliminate my use of znv in my project as it was just a nice-to-have anyway. (Deployment was successful without znv.)

@appurist
Copy link
Author

Sorry I just saw issue #2 which is clearly related if not a duplicate.

@appurist
Copy link
Author

Reading #2 in more detail, yes it is a duplicate! Sorry for the new issue.

@appurist appurist closed this as not planned Won't fix, can't repro, duplicate, stale Dec 14, 2023
@lostfictions
Copy link
Owner

@appurist I've just pushed #15 which should add Vercel and Cloudflare support -- please take a look if you can!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants