Skip to content

formatWebpackMessages shouldn't use chalk #8583

New issue

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

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

Already on GitHub? # to your account

Closed
MOZGIII opened this issue Feb 29, 2020 · 3 comments
Closed

formatWebpackMessages shouldn't use chalk #8583

MOZGIII opened this issue Feb 29, 2020 · 3 comments

Comments

@MOZGIII
Copy link

MOZGIII commented Feb 29, 2020

Describe the bug

I have an error below:

index.js:8 Uncaught ReferenceError: process is not defined
    at Object../node_modules/chalk/index.js (index.js:8)
    at __webpack_require__ (bootstrap:734)
    at fn (bootstrap:100)
    at Object../node_modules/react-dev-utils/formatWebpackMessages.js (formatWebpackMessages.js:10)
    at __webpack_require__ (bootstrap:734)
    at fn (bootstrap:100)
    at Object../node_modules/@pmmmwh/react-refresh-webpack-plugin/src/runtime/ErrorOverlayEntry.js (ErrorOverlayEntry.js:5)
    at __webpack_require__ (bootstrap:734)
    at fn (bootstrap:100)
    at Object.0 (index.tsx:12)

It's caused by a deep dependency of my app, but I deduced the right place to correct this may be here.

I'm not using CRA directly, and running this in an electron app that has sandboxed access to a subset of nodejs API.

Environment

  • react-dev-utils 9.1.0; master in the repo currently has the same behavior.
  • webpack 4, babel 7 and so on, but this is irrelevant as workarounds won't cover my use case.

Expected behavior

I expect react-dev-utils/formatWebpackMessages.js to not use chalk, since it's not used in the cli context. chalk requires Node APIs to be available.

Actual behavior

I got an exception. cause chalk has const isSimpleWindowsTerm = process.platform === 'win32' && !(process.env.TERM || '').toLowerCase().startsWith('xterm');. It's not adopted for browser use.

Reproducible demo

Sorry.

@jurosh
Copy link

jurosh commented Mar 12, 2020

Same issue here after upgrade to the latest version. I am using react-scripts directly.

Just having config.node = false; to remove some node deps being included in the bundle -- using react-app-rewire

As workaround need to revert back to version 3.3.1. Problem is just with latest 3.4.0

@stale
Copy link

stale bot commented Apr 11, 2020

This issue has been automatically marked as stale because it has not had any recent activity. It will be closed in 5 days if no further activity occurs.

@stale stale bot added the stale label Apr 11, 2020
@stale
Copy link

stale bot commented Apr 17, 2020

This issue has been automatically closed because it has not had any recent activity. If you have a question or comment, please open a new issue.

@stale stale bot closed this as completed Apr 17, 2020
@lock lock bot locked and limited conversation to collaborators Apr 25, 2020
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Projects
None yet
Development

No branches or pull requests

2 participants