forked from vercel/next.js
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add checking of react versions (vercel#6892)
* Add checking of react versions to make sure it meets the minimum set in peerDependencies * Simplify react check * Update error wording Co-Authored-By: timneutkens <[email protected]> * Add err.sh * Update test-production circleci job name * Add react error message to next-dev-server * Update test for new wording
- Loading branch information
Showing
5 changed files
with
39 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Invalid React Version | ||
|
||
#### Why This Error Occurred | ||
|
||
You tried running `next` in a project with an incompatible react version. Next.js uses certain react features that when are unavailable show this error since it can't work without them. | ||
|
||
#### Possible Ways to Fix It | ||
|
||
Run `npm i react@latest react-dom@latest` or `yarn add react@latest react-dom@latest` in your project and then try running `next` again. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/* eslint-env jest */ | ||
import path from 'path' | ||
|
||
jest.mock('react', () => ({ | ||
Suspense: undefined | ||
})) | ||
|
||
const nextDir = path.dirname(require.resolve('next/package')) | ||
const nextBin = path.join(nextDir, 'dist/bin/next') | ||
|
||
describe('Handles Incorrect React Version', () => { | ||
it('should throw an error when building with next', async () => { | ||
expect(() => require(nextBin)).toThrow(/The version of React you are using is lower than the minimum required version needed for Next\.js\. Please upgrade "react" and "react-dom": "npm install --save react react-dom" https:\/\/err\.sh/) | ||
}) | ||
}) |