Fix require('next')
when this plugin is pre-installed
#55
Labels
require('next')
when this plugin is pre-installed
#55
In production, we pre-install Build plugins in
/opt/buildhome/.netlify-build-plugins
. However, the repository is in/opt/build/repo
. Therefore, trying to require a dependency of the site (also known as peer dependency) from a plugin does not work. This problem is described in details in this issue.In the case of both this plugin and
next-on-netlify
, we are doingrequire('next')
. We are doing this to allow users to choose their own Next.js version instead of forcing one (see #25). This currently fails in production due to the problem above.The proper solution to this problem is detailed in this issue. However, this is not a quick fix, so we need an alternative in the meantime.
The only solution I can think of is the following: if we detect that the plugin is run in production, use
require.resolve()
to locatenext
. In practice this would mean lines like:would be changed to:
This is hacky. This would need to be done in
next-on-netlify
too.What do you think?
The text was updated successfully, but these errors were encountered: