From 16fe95778e5f01d1d228151cd626ad3abc869f27 Mon Sep 17 00:00:00 2001 From: Dan Abramov <dan.abramov@gmail.com> Date: Wed, 7 Dec 2016 16:06:35 +0000 Subject: [PATCH] Only honor relative NODE_PATH (#1194) --- packages/react-scripts/config/paths.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/react-scripts/config/paths.js b/packages/react-scripts/config/paths.js index d15b16a054..2f10ea2fb8 100644 --- a/packages/react-scripts/config/paths.js +++ b/packages/react-scripts/config/paths.js @@ -30,9 +30,14 @@ function resolveApp(relativePath) { // It will then be used by Webpack configs. // Jest doesn’t need this because it already handles `NODE_PATH` out of the box. +// Note that unlike in Node, only *relative* paths from `NODE_PATH` are honored. +// Otherwise, we risk importing Node.js core modules into an app instead of Webpack shims. +// https://github.com/facebookincubator/create-react-app/issues/1023#issuecomment-265344421 + var nodePaths = (process.env.NODE_PATH || '') .split(process.platform === 'win32' ? ';' : ':') .filter(Boolean) + .filter(folder => !path.isAbsolute(folder)) .map(resolveApp); // config after eject: we're in ./config/