-
Notifications
You must be signed in to change notification settings - Fork 27.2k
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
Detect node sass and react version #13968
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# Correct sass dependency | ||
|
||
#### Why This Error Occurred | ||
|
||
You are using both _sass_ and _node-sass_ in your project. | ||
|
||
#### Possible Ways to Fix It | ||
|
||
Your dependencies should contain only one of both, preferably node-sass. | ||
|
||
They should look like this | ||
|
||
```js | ||
"dependencies": { | ||
"node-sass": "^4.14.1", | ||
} | ||
``` | ||
|
||
instead of this | ||
|
||
```js | ||
"dependencies": { | ||
"node-sass": "^4.14.1", | ||
"sass": "^1.26.8" | ||
} | ||
``` | ||
|
||
### Useful Links | ||
|
||
- [Related issue](https://github.com/vercel/next.js/issues/6681) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# Minimum React version | ||
|
||
#### Why This Error Occurred | ||
|
||
The version of react you are using is older than 16.10. | ||
Next.js requires React 16.10 or newer for Fast Refresh to work correctly. | ||
On older versions, Next.js will fallback to full page reload every time. | ||
|
||
Please, take in mind that in this case your dev experience would be suboptimal and unexpected behaviour may occour. | ||
|
||
#### Possible Ways to Fix It | ||
|
||
Be sure your React version is 16.10 or newer. | ||
|
||
```js | ||
"dependencies": { | ||
"react": "16.10", | ||
} | ||
``` | ||
|
||
### Useful Links | ||
|
||
- [fast-refresh](https://nextjs.org/blog/next-9-4#fast-refresh) | ||
- [react-refresh](https://github.com/facebook/react/tree/master/packages/react-refresh) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -263,6 +263,26 @@ export default async function getBaseWebpackConfig( | |
resolvedBaseUrl = path.resolve(dir, jsConfig.compilerOptions.baseUrl) | ||
} | ||
|
||
if (isServer) { | ||
const packageJsonPath = path.resolve(dir, './package.json') | ||
const packageJsonFile = parseJsonFile(packageJsonPath) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Checking the version of React in their package.json might not be comprehensive enough. They could have I think checking their installed dependencies might give you a bit more coverage: const packagePath = require.resolve('react/package.json')
const { version } = require(packagePath) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Noted! Will change it! |
||
const { dependencies } = packageJsonFile | ||
if (dependencies['react']) { | ||
const version = +dependencies['react'].substr(0, 5) | ||
if (version < 16.1) { | ||
console.warn( | ||
'Next.js requires React 16.10 or newer for Fast Refresh to work correctly. https://err.sh/next.js/minimum-react-version' | ||
) | ||
} | ||
} | ||
|
||
if (dependencies['node-sass'] != null && dependencies['sass'] != null) { | ||
console.warn( | ||
'It is not recommended to use node-sass and sass together. https://err.sh/next.js/correct-sass-dependency' | ||
) | ||
} | ||
} | ||
|
||
const resolveConfig = { | ||
// Disable .mjs for node_modules bundling | ||
extensions: isServer | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The check should exist in
packages/next/cli/next-dev.ts