-
Notifications
You must be signed in to change notification settings - Fork 95
Closed
Labels
proj/non/next-on-netlify-enterprisetype: bugcode to address defects in shipped codecode to address defects in shipped code
Description
next-on-netlify requires next as a peerDependency:
This repository requires next-on-netlify as a production dependency:
If a site is using this plugin, but forgot to install next, this plugin will thrown when being require()'d, as opposed to when onPreBuild is run. This results in an error message which might be confusing:
Uncaught Error: Cannot find module 'next/constants'
Require stack:
- /home/ether/Desktop/node_modules/next-on-netlify/lib/helpers/getNextDistDir.js
- /home/ether/Desktop/node_modules/next-on-netlify/lib/config.js
- /home/ether/Desktop/node_modules/next-on-netlify/lib/steps/prepareFolders.js
- /home/ether/Desktop/node_modules/next-on-netlify/index.js
- /home/ether/Desktop/node_modules/@netlify/plugin-nextjs/index.js
- <repl>
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:900:15)
at Function.Module._load (node:internal/modules/cjs/loader:745:27)
at Module.require (node:internal/modules/cjs/loader:972:19)
at require (node:internal/modules/cjs/helpers:88:18) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'/home/ether/Desktop/node_modules/next-on-netlify/lib/helpers/getNextDistDir.js',
'/home/ether/Desktop/node_modules/next-on-netlify/lib/config.js',
'/home/ether/Desktop/node_modules/next-on-netlify/lib/steps/prepareFolders.js',
'/home/ether/Desktop/node_modules/next-on-netlify/index.js',
'/home/ether/Desktop/node_modules/@netlify/plugin-nextjs/index.js',
'<repl>'
]
}
To fix this:
nextandnext-on-netlifyshould berequire()'donly inside theif (isNextProject) { ... }block_isNextProject()should try torequire('next'), and returnfalseif that throws an error
We might want to also wonder: are we ok with this plugin requiring users to install Next.js as a dependency (as opposed to doing it for them)?
Metadata
Metadata
Assignees
Labels
proj/non/next-on-netlify-enterprisetype: bugcode to address defects in shipped codecode to address defects in shipped code