Skip to content

Commit

Permalink
fix: check resolvedNodePath for Next.js 12 guard (#19604)
Browse files Browse the repository at this point in the history
  • Loading branch information
ZachJW34 committed Jan 10, 2022
1 parent 10e3e0a commit 6304fd7
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions npm/react/plugins/next/checkSWC.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ export function checkSWC (
)
})

if (hasSWCLoader && cypressConfig.nodeVersion !== 'system') {
throw new Error(`Cypress requires "nodeVersion" to be set to "system" in order to run Next.js with SWC optimizations.
Please add "nodeVersion": "system" to your Cypress configuration and try again.`)
// "resolvedNodePath" is only set when using the user's Node.js, which is required to compile Next.js with SWC optimizations
// If it is not set, they have either explicitly set "nodeVersion" to "bundled" or are are using Cypress < 9.0.0 where it was set to "bundled" by default
if (hasSWCLoader && !cypressConfig.resolvedNodePath) {
throw new Error(`Cannot compile Next.js application with configured Node.js.
If you are on Cypress version >= \`9.0.0\`, remove the "nodeVersion" property from your Cypress config. Otherwise, please add "nodeVersion": "system" to your Cypress config and try again.`)
}

return false
Expand Down

0 comments on commit 6304fd7

Please sign in to comment.