Created by: gaearon
This behavior was originally introduced in #1359 as we thought it would fix the npm link
development workflow issues.
However, we have since found several problems with it:
- It doesn’t match the Node resolution mechanism (which reverted a similar change in https://github.com/nodejs/node/pull/6537 and kept it behind a flag)
- It still leads to the “duplicate React” problem (#675)
- It is inconsistent with Jest (as described in https://github.com/facebookincubator/create-react-app/issues/3883, past versions of Jest had this behavior but it led to issues like https://github.com/facebook/jest/issues/3830 and https://github.com/facebook/jest/pull/4761#issuecomment-339419335 so I fixed it in https://github.com/facebook/jest/pull/4761 to match the Node resolution mechanism)
There are also gotchas like https://github.com/webpack/webpack/issues/985#issuecomment-280253786, and I feel like it’s only going to get worse once we start supporting monorepos (#3741).
I propose that we completely disable this behavior for now. People who really need it can use an escape hatch: add NODE_PATH=node_modules
to their .env
file. This restores the 1.x behavior (and conveniently works in Jest too).
Our recommendation in any case will be to use monorepos instead (#3741) and stop relying on npm link
.