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

turn off colors if not TTY #77171

Open
ORESoftware opened this issue Mar 16, 2025 · 0 comments
Open

turn off colors if not TTY #77171

ORESoftware opened this issue Mar 16, 2025 · 0 comments
Labels
linear: turbopack Confirmed issue that is tracked by the Turbopack team. Turbopack Related to Turbopack with Next.js.

Comments

@ORESoftware
Copy link

Link to the code that reproduces this issue

nodejs/nodejs.org#7544

To Reproduce

The dev server (in turbo mode) seems to write to a non-TTY, which is fine - I have this:

next_dev_turbo(){
  export NO_COLOR=1
  export FORCE_COLOR=0
  export TERM=dumb
  export NEXT_DISABLE_COLOR=1
  export NEXT_DISABLE_ANSI=1  # Specific to Next.js ?
  next dev --turbo
}

but I still get a bunch of colors (escape chars)

{"level":40,"time":1742138335605,"pid":84224,"hostname":"MacBook-Pro.local","name":"console","msg":"ddl:WARN (server)  ⚠ ./src/lib/server/utils/dd-error.ts:8:33\nEcmascript file had an error\n\u001b[0m \u001b[90m  6 |\u001b[39m\u001b[0m\n\u001b[0m \u001b[90m  7 |\u001b[39m \u001b[36mif\u001b[39m( \u001b[36mtypeof\u001b[39m process \u001b[33m!==\u001b[39m \u001b[32m'undefined'\u001b[39m){\u001b[0m\n\u001b[0m\u001b[31m\u001b[1m>\u001b[22m\u001b[39m\u001b[90m  8 |\u001b[39m   \u001b[36mif\u001b[39m (process\u001b[33m?\u001b[39m\u001b[33m.\u001b[39menv\u001b[33m?\u001b[39m\u001b[33m.\u001b[39m\u001b[33mNO_COLOR\u001b[39m \u001b[33m||\u001b[39m process\u001b[33m?\u001b[39m\u001b[33m.\u001b[39margv\u001b[33m?\u001b[39m\u001b[33m.\u001b[39mincludes(\u001b[32m'--no-color'\u001b[39m)) {\u001b[0m\n\u001b[0m \u001b[90m    |\u001b[39m                                 \u001b[31m\u001b[1m^\u001b[22m\u001b[39m\u001b[31m\u001b[1m^\u001b[22m\u001b[39m\u001b[31m\u001b[1m^\u001b[22m\u001b[39m\u001b[31m\u001b[1m^\u001b[22m\u001b[39m\u001b[31m\u001b[1m^\u001b[22m\u001b[39m\u001b[31m\u001b[1m^\u001b[22m\u001b[39m\u001b[31m\u001b[1m^\u001b[22m\u001b[39m\u001b[31m\u001b[1m^\u001b[22m\u001b[39m\u001b[31m\u001b[1m^\u001b[22m\u001b[39m\u001b[31m\u001b[1m^\u001b[22m\u001b[39m\u001b[31m\u001b[1m^\u001b[22m\u001b[39m\u001b[31m\u001b[1m^\u001b[22m\u001b[39m\u001b[31m\u001b[1m^\u001b[22m\u001b[39m\u001b[0m\n\u001b[0m \u001b[90m  9 |\u001b[39m     chalk\u001b[33m.\u001b[39mlevel \u001b[33m=\u001b[39m \u001b[35m0\u001b[39m\u001b[33m;\u001b[39m\u001b[0m\n\u001b[0m \u001b[90m 10 |\u001b[39m   }\u001b[0m\n\u001b[0m \u001b[90m 11 |\u001b[39m }\u001b[0m\n\nA Node.js API is used (process.argv at line: 8) which is not supported in the Edge Runtime.\nLearn more: https://nextjs.org/docs/api-reference/edge-runtime\n\n"}
{"level":40,"time":1742138335606,"pid":84224,"hostname":"MacBook-Pro.local","name":"console","msg":"ddl:WARN (server)  ⚠ ./src/lib/server/utils/dd-error.ts:18:51\nEcmascript file had an error\n\u001b[0m \u001b[90m 16 |\u001b[39m \u001b[36mimport\u001b[39m { encryptSync } \u001b[36mfrom\u001b[39m \u001b[32m'@/lib/server/utils/encrypt-sync'\u001b[39m\u001b[33m;\u001b[39m\u001b[0m\n\u001b[0m \u001b[90m 17 |\u001b[39m\u001b[0m\n\u001b[0m\u001b[31m\u001b[1m>\u001b[22m\u001b[39m\u001b[90m 18 |\u001b[39m \u001b[36mconst\u001b[39m isNode \u001b[33m=\u001b[39m \u001b[36mtypeof\u001b[39m process \u001b[33m!==\u001b[39m \u001b[32m'undefined'\u001b[39m \u001b[33m&&\u001b[39m (process\u001b[

I think it's just not recognizing that's connected to a non-TTY - it really should not put out colors in that case.

Current vs. Expected behavior

The dev server (in turbo mode) seems to write to a non-TTY, which is fine - I have this:

next_dev_turbo(){
  export NO_COLOR=1
  export FORCE_COLOR=0
  export TERM=dumb
  export NEXT_DISABLE_COLOR=1
  export NEXT_DISABLE_ANSI=1  # Specific to Next.js ?
  next dev --turbo
}

but I still get a bunch of colors (escape chars)

{"level":40,"time":1742138335605,"pid":84224,"hostname":"MacBook-Pro.local","name":"console","msg":"ddl:WARN (server)  ⚠ ./src/lib/server/utils/dd-error.ts:8:33\nEcmascript file had an error\n\u001b[0m \u001b[90m  6 |\u001b[39m\u001b[0m\n\u001b[0m \u001b[90m  7 |\u001b[39m \u001b[36mif\u001b[39m( \u001b[36mtypeof\u001b[39m process \u001b[33m!==\u001b[39m \u001b[32m'undefined'\u001b[39m){\u001b[0m\n\u001b[0m\u001b[31m\u001b[1m>\u001b[22m\u001b[39m\u001b[90m  8 |\u001b[39m   \u001b[36mif\u001b[39m (process\u001b[33m?\u001b[39m\u001b[33m.\u001b[39menv\u001b[33m?\u001b[39m\u001b[33m.\u001b[39m\u001b[33mNO_COLOR\u001b[39m \u001b[33m||\u001b[39m process\u001b[33m?\u001b[39m\u001b[33m.\u001b[39margv\u001b[33m?\u001b[39m\u001b[33m.\u001b[39mincludes(\u001b[32m'--no-color'\u001b[39m)) {\u001b[0m\n\u001b[0m \u001b[90m    |\u001b[39m                                 \u001b[31m\u001b[1m^\u001b[22m\u001b[39m\u001b[31m\u001b[1m^\u001b[22m\u001b[39m\u001b[31m\u001b[1m^\u001b[22m\u001b[39m\u001b[31m\u001b[1m^\u001b[22m\u001b[39m\u001b[31m\u001b[1m^\u001b[22m\u001b[39m\u001b[31m\u001b[1m^\u001b[22m\u001b[39m\u001b[31m\u001b[1m^\u001b[22m\u001b[39m\u001b[31m\u001b[1m^\u001b[22m\u001b[39m\u001b[31m\u001b[1m^\u001b[22m\u001b[39m\u001b[31m\u001b[1m^\u001b[22m\u001b[39m\u001b[31m\u001b[1m^\u001b[22m\u001b[39m\u001b[31m\u001b[1m^\u001b[22m\u001b[39m\u001b[31m\u001b[1m^\u001b[22m\u001b[39m\u001b[0m\n\u001b[0m \u001b[90m  9 |\u001b[39m     chalk\u001b[33m.\u001b[39mlevel \u001b[33m=\u001b[39m \u001b[35m0\u001b[39m\u001b[33m;\u001b[39m\u001b[0m\n\u001b[0m \u001b[90m 10 |\u001b[39m   }\u001b[0m\n\u001b[0m \u001b[90m 11 |\u001b[39m }\u001b[0m\n\nA Node.js API is used (process.argv at line: 8) which is not supported in the Edge Runtime.\nLearn more: https://nextjs.org/docs/api-reference/edge-runtime\n\n"}
{"level":40,"time":1742138335606,"pid":84224,"hostname":"MacBook-Pro.local","name":"console","msg":"ddl:WARN (server)  ⚠ ./src/lib/server/utils/dd-error.ts:18:51\nEcmascript file had an error\n\u001b[0m \u001b[90m 16 |\u001b[39m \u001b[36mimport\u001b[39m { encryptSync } \u001b[36mfrom\u001b[39m \u001b[32m'@/lib/server/utils/encrypt-sync'\u001b[39m\u001b[33m;\u001b[39m\u001b[0m\n\u001b[0m \u001b[90m 17 |\u001b[39m\u001b[0m\n\u001b[0m\u001b[31m\u001b[1m>\u001b[22m\u001b[39m\u001b[90m 18 |\u001b[39m \u001b[36mconst\u001b[39m isNode \u001b[33m=\u001b[39m \u001b[36mtypeof\u001b[39m process \u001b[33m!==\u001b[39m \u001b[32m'undefined'\u001b[39m \u001b[33m&&\u001b[39m (process\u001b[

I think it's just not recognizing that's connected to a non-TTY - it really should not put out colors in that case.

Provide environment information

Next.js v15.1.6
Node version 22.13.0

Which area(s) are affected? (Select all that apply)

Turbopack

Which stage(s) are affected? (Select all that apply)

next dev (local)

Additional context

No response

@github-actions github-actions bot added the Turbopack Related to Turbopack with Next.js. label Mar 16, 2025
@mischnic mischnic added the linear: turbopack Confirmed issue that is tracked by the Turbopack team. label Mar 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
linear: turbopack Confirmed issue that is tracked by the Turbopack team. Turbopack Related to Turbopack with Next.js.
Projects
None yet
Development

No branches or pull requests

2 participants