GithubHelp home page GithubHelp logo

netlify / next-runtime Goto Github PK

View Code? Open in Web Editor NEW
600.0 16.0 86.0 107.78 MB

The Next.js Runtime allows Next.js to run on Netlify with zero configuration

Home Page: https://www.npmjs.com/package/@netlify/plugin-nextjs

JavaScript 21.98% TypeScript 77.60% CSS 0.37% Sass 0.03% SCSS 0.03%
netlify-plugin nextjs javascript netlify

next-runtime's Introduction

Next.js Runtime

Next.js Runtime

Note

Next.js Runtime v5 is available for early access! Please note that this repository is for the current version (v4) of the Next.js Runtime, and the early access version is not yet available in this repository. Learn more.

Next.js is supported natively on Netlify, and in most cases you will not need to install or configure anything. This repo includes the packages used to support Next.js on Netlify.

Deploying

If you build on Netlify, the Next.js Runtime will work with no additional configuration. However if you are building and deploying locally using the Netlify CLI, you must deploy using netlify deploy --build. Running the build and deploy commands separately will not work, because the Next.js Runtime will not generate the required configuration.

Using next/image

If you use next/image, your images will be automatically optimized at runtime, ensuring that they are served at the best size and format. The image will be processed on the first request which means it may take longer to load, but the generated image is then cached and served as a static file to future visitors. By default, Next.js will deliver WebP images if the browser supports it. WebP is a modern image format with wide browser support that will usually generate smaller files than PNG or JPG. Additionally, you can enable AVIF format, which is often even smaller in filesize than WebP. The drawback is that with particularly large images, AVIF images may take too long to generate, and the function times-out. You can configure the supported image formats in your next.config.js file.

Enabling Edge Images

It is possible to run image content negotiation on the edge. This allows images to be processed on the first request, and then, in future loads, served from cache on the edge.

In order to deliver the correct format to a visitor's browser, this uses a Netlify Edge Function. In some cases your site may not support Edge Functions, in which case it will instead fall back to delivering the original file format.

To turn on Edge image handling for Next/Image, set the environment variable NEXT_FORCE_EDGE_IMAGES to true

Returning custom response headers on images handled by ipx

Should you wish to return custom response headers on images handled by the netlify-ipx package, you can add them within your project's netlify.toml by targeting the /_next/image/* route:

[[headers]]
  for = "/_next/image/*"

  [headers.values]
    Strict-Transport-Security = "max-age=31536000"
    X-Test = 'foobar'

Disabling included image loader

If you wish to disable the use of the image loader which is bundled into the runtime by default, set the DISABLE_IPX environment variable to true.

This should only be done if the site is not using next/image or is using a different loader (such as Cloudinary or Imgix).

See the Next.js documentation for image loader options.

Next.js Middleware on Netlify

Next.js Middleware works out of the box on Netlify. By default, middleware runs using Netlify Edge Functions. For legacy support for running Middleware at the origin, set the environment variable NEXT_DISABLE_NETLIFY_EDGE to true. Be aware that this will result in slower performance, as all pages that match middleware must use SSR.

For more details on Next.js Middleware with Netlify, see the middleware docs.

Limitations

Due to how the site configuration is handled when it's run using Netlify Edge Functions, data such as locale and defaultLocale will be missing on the req.nextUrl object when running netlify dev.

However, this data is available on req.nextUrl in a production environment.

Monorepos

If you are using a monorepo you will need to change publish to point to the full path to the built .next directory, which may be in a subdirectory. If you have changed your distDir then it will need to match that.

If you are using Nx, then you will need to point publish to the folder inside dist, e.g. dist/apps/myapp/.next.

Incremental Static Regeneration (ISR)

The Next.js Runtime fully supports ISR on Netlify. For more details see the ISR docs.

Note that Netlify has a minimum TTL of 60 seconds for revalidation.

Disable Static 404 on Dynamic Routes with fallback:false

Currently when hitting a non-prerendered path with fallback=false it will default to a 404 page. You can now change this default setting by using the environemnt variable LEGACY_FALLBACK_FALSE=true. With the environment variable set, those non-prerendered paths will now be routed through using the ISR Handler and will allow you to add redirects for those non-prerendered paths.

Use with next export

If you are using next export to generate a static site, you do not need most of the functionality of this Next.js Runtime and you can remove it. Alternatively you can set the environment variable NETLIFY_NEXT_PLUGIN_SKIP to true and the Next.js Runtime will handle caching but won't generate any functions for SSR support. See demos/next-export for an example.

Asset optimization

Netlify asset optimization should not be used with Next.js sites. Assets are already optimized by Next.js at build time, and doing further optimization can break your site. Ensure that it is not enabled at Site settings > Build & deploy > Post processing > Asset optimization.

Generated functions

The Next.js Runtime works by generating three Netlify functions that handle requests that haven't been pre-rendered. These are ___netlify-handler (for SSR and API routes), ___netlify-odb-handler (for ISR and fallback routes), and _ipx (for images). You can see the requests for these in the function logs. For ISR and fallback routes you will not see any requests that are served from the edge cache, just actual rendering requests. These are all internal functions, so you won't find them in your site's own functions directory.

The Next.js Runtime will also generate a Netlify Edge Function called 'ipx' to handle image content negotiation, and if Edge runtime or middleware is enabled it will also generate edge functions for middleware and edge routes.

Manually installing the Next.js Runtime

The Next.js Runtime installs automatically for new Next.js sites on Netlify. You can also install it manually in the following ways:

From the UI (Recommended):

You can go to the UI and choose the site to install the Next.js Runtime on. This method is recommended because you will benefit from auto-upgrades to important fixes and feature updates.

From npm:

npm install -D @netlify/plugin-nextjs

...then add the following to your netlify.toml file:

[[plugins]]
  package = "@netlify/plugin-nextjs"

This method is recommended if you wish to pin the Next.js Runtime to a specific version.

Manually upgrading from an older version of the Next.js Runtime

If you previously set these values, they're no longer needed and should be removed:

  • distDir in your next.config.js
  • node_bundler = "esbuild" in netlify.toml
  • external_node_modules in netlify.toml
  • The environment variable NEXT_USE_NETLIFY_EDGE can be removed as this is now the default

The serverless and experimental-serverless-trace targets are deprecated in Next.js 12, and all builds with this Next.js Runtime will now use the default server target. If you previously set the target in your next.config.js, you should remove it.

If you currently use redirects or rewrites on your site, see the Rewrites and Redirects guide for information on changes to how they are handled in this version. In particular, note that _redirects and _headers files must be placed in public, not in the root of the site.

Using with pnpm

If your site uses pnpm to manage dependencies, currently you must enable public hoisting. The simplest way to do this is to create a .npmrc file in the root of your project with the content:

public-hoist-pattern[]=*

Running the tests

To run the tests, ensure that the dependencies are installed as follows:

npm install

Then run the tests:

npm test

End-to-end tests

In order to run the end-to-end (E2E) tests, you'll need to be logged in to Netlify. You can do this using the Netlify CLI with the command:

netlify login

Alternatively, you can set an environment variable NETLIFY_AUTH_TOKEN to a valid Netlify personal access token. This can be obtained from the Netlify UI.

Then run the E2E tests if logged in:

npm run test:next

Or if using an access token:

NETLIFY_AUTH_TOKEN=your-token-here npm run test:next

Note: The E2E tests will be deployed to a Netlify owned site. To deploy to your own site then set the environment variable NETLIFY_SITE_ID to your site ID.

Feedback

If you think you have found a bug in Next.js on Netlify, please open an issue. If you have comments or feature requests, see the discussion board

next-runtime's People

Contributors

ascorbic avatar chenders avatar danez avatar dependabot[bot] avatar dustincrogers avatar dwwoelfel avatar ehmicky avatar erezrokah avatar ericapisani avatar grountish avatar hs-netlify avatar lekoarts avatar lindsaylevine avatar marcl avatar nickytonline avatar orinokai avatar pcn avatar pieh avatar renovate-bot avatar renovate[bot] avatar rohitrajendran avatar rstavchansky avatar sarahetter avatar scouttyg avatar skn0tt avatar stephmarie17 avatar taty2010 avatar tiffafoo avatar token-generator-app[bot] avatar zachleat avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

next-runtime's Issues

missing "jimp" dependency

related to #84, I think

[email protected] introduced image support, which relies on jimp. however, this plugin is set to @2.7.2 and that is somehow causing the next image support to run, but jimp is not installed as a dependency

I don't know how or why, but wanted to track this here

Error: Your next.config.js must set the "target" property to one of: serverless, experimental-serverless-trace for conditional target

I'm using a conditional to determine if our next application will be compiled in server or serverless mode. The plugin, however, does not support this kind of config:

const isServerless = !!process.env['NEXT_SERVERLESS'];

module.exports = withOptimizedImages(
    withBundleAnalyzer(
        withSourceMaps({
            target: isEnvProduction && isServerless ? 'serverless' : 'server',
            poweredByHeader: false,
            ...
      })
    )
);

My netlify.toml looks like this:

[build]
    command   = "yarn run build:serverless"
    functions = "out_functions"
    publish   = "out_publish"

[[plugins]]
  package = "@netlify/plugin-nextjs"

The build:serverless task sets the environment variable NEXT_SERVERLESS:

"build:serverless": "yarn run clean && NODE_ENV=production NEXT_SERVERLESS=true SOURCE_MAPS_ENABLED=false next build",

A workaround is to sed the config in our CI pipeline before running netlify build:

sed -i "s/target: isEnvProduction && isServerless ? 'serverless' : 'server',/target: 'serverless',/g" next.config.js

Getting 404 on Netlify Form submit

On submitting an ajax form to Netlify Forms, I'm getting a 404 page being served. I have no special _redirects rules either.

curl 'https://beta.dfame.app/' \
  -H 'user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.66 Safari/537.36' \
  -H 'content-type: application/x-www-form-urlencoded' \
  -H 'referer: https://beta.dfame.app/' \
  -H 'accept-language: en-US,en;q=0.9' \
  -H 'cookie: _gid=GA1.2.1550095432.1605983334; _ga=GA1.1.1307560562.1605983334; _ga_37514942YF=GS1.1.1606014014.5.1.1606017875.0' \
  --data-raw 'form-name=tppCreate&email=a%40az.com&url=demo.ghost.io&address=&balance=1' \
  --compressed

Small performance improvement

We are currently calling listFrameworks() twice, once for onPreBuild, once for onPostBuild.
We could instead keep the result of the first call in a top-level variable, so onPostBuild does not need to perform that slow operation again.

Support next.config.js redirects, rewrites, headers

First of all, thank you for the amazing work with this package!

Currently when defining experimental rewrites in next.config.js they are not respected in netlify and throw 404 error from netlify. Any chance they can be supported?

example of the config file:

module.exports = {
  target: 'serverless',
  experimental: {
    redirects() {
      const redirects = [
        {
          // Redirect root link with trailing slash to non-trailing slash, avoids 404 - See https://github.com/vercel/next.js/discussions/10651#discussioncomment-8270
          source: '/:locale/',
          destination: '/:locale',
          permanent: process.env.NEXT_PUBLIC_APP_STAGE !== 'development', // Do not use permanent redirect locally to avoid browser caching when working on it
        },
        {
          // Redirect link with trailing slash to non-trailing slash (any depth), avoids 404 - See https://github.com/vercel/next.js/discussions/10651#discussioncomment-8270
          source: '/:locale/:path*/',
          destination: '/:locale/:path*',
          permanent: true
        },
      ];

      return redirects;
    },
    rewrites() {
      const rewrites = [
        {
          source: '/',
          destination: '/api/autoRedirectToLocalisedPage',
        },
        {
          source: `/:locale((?!${noRedirectBasePaths.join('|')})[^/]+)(.*)`,
          destination: '/api/autoRedirectToLocalisedPage',
        },
      ];

      return rewrites;
    },
  },
};

Improve next/image performance

This issue follows up netlify/next-on-netlify#70. Initial support for next/image was merged in netlify/next-on-netlify#138. However, that initial support is not performant since the Netlify function will re-run on every request without any caching.

Our next step is to improve this performance with caching. This will depend on internal work at Netlify. Please follow this issue for updates on next/image performance!! :)

Error: next.config.js must be one of: serverless, experimental-serverless-trace

I'm getting the following error on my fresh netlify app:

7:03:03 PM:   Error message
7:03:03 PM:   Error: next.config.js must be one of: serverless, experimental-serverless-trace
7:03:03 PM: ​
7:03:03 PM:   Plugin details
7:03:03 PM:   Package:        @netlify/plugin-nextjs
7:03:03 PM:   Version:        1.0.5
7:03:03 PM:   Repository:     git+https://github.com/netlify/netlify-plugin-nextjs.git
7:03:03 PM:   npm link:       https://www.npmjs.com/package/@netlify/plugin-nextjs
7:03:03 PM:   Report issues:  https://github.com/netlify/netlify-plugin-nextjs/issues
7:03:03 PM: ​
7:03:03 PM:   Error location
7:03:03 PM:   In "onPreBuild" event in "@netlify/plugin-nextjs" from Netlify app
7:03:03 PM:       at onPreBuild (/.netlify/plugins/node_modules/@netlify/plugin-nextjs/index.js:60:16)

I have the following plugins:

7:02:40 PM:    - @netlify/[email protected]
7:02:40 PM:    - [email protected]

Feature: don't fail the build if the site doesn't match the requirements

The plugin currently fails the build if:

  1. This site is not a next site
  2. The site is a static HTML export Next.js site
  3. The site has next-on-netlify installed
  4. The site configures a target other than serverless or experimental-serverless-trace

Per https://github.com/netlify/pod-workflow/issues/121#issuecomment-763411132 I suggest to change it to only fail if it's not a next site.

For all other cases we can print a relevant message and do nothing.

Do not require `react` nor `react-dom`

We currently use require('next') to check whether the website is using Next.js.
However, this requires react and react-dom to also be available.
Doing require('next/package.json') instead should solve this. It's also faster.

Remove intermediary copy steps

All Next.js page/function files are initially copied by next-on-netlify to out_functions and out_publish.
This plugin then copies all those files from out_functions and out_publish to the site's Functions/publish directories.

If those are lots of files, this additional copy step might end take lots of build time. Instead, we could remove that intermediary step:

  • Make the main function exported by netlify-on-netlify accepts an options object so users can customize the location of out_functions and out_publish:

https://github.com/netlify/next-on-netlify/blob/a9dade3824d1288770d967cc6f57f238d5947367/index.js#L7

const nextOnNetlify = ({ functionsDir = "out_functions", publishDir = "out_publish" } = {}) => {
  • Pass constants.FUNCTIONS_SRC and constants.PUBLISH_DIR to next-on-netlify
  • Remove the additional copy step 🎉

https://github.com/netlify/netlify-plugin-nextjs/blob/84c6f7f4ccfd6d814bd642d0a27921ef49b67c25/index.js#L74

As a follow-up, we can also expose those to next-on-netlify CLI.

What do you think @lindsaylevine?

Improve speed by parallelizing I/O

Most of the logic from next-on-netlify is I/O read/write operations. Those are currently performed serially. Performing those in parallel instead would significantly improve performance.

A queue should probably be used so that the OS max limits on open files is not reached.

@lindsaylevine

Remove `npm install next-on-netlify`

Potential improvement of redirects

One of our Netlify Build plugins generates a _redirects file based on the .next/routes-manifest.json. In particular, it uses the dynamicRoutes property in that file and converts those to lines appended to the _redirects file.

Link to source code

next-on-netlify also includes some logic to convert Next.js redirects to Netlify. Is there anything useful in that plugin which could be added to next-on-netlify?

Either way, we should also consider removing that plugin from our list of plugins if @netlify/plugin-nextjs covers the same use cases.

@lindsaylevine

How can we use this plugin for manual deploys through cli?

First of all, thanks for a very nice and useful plugin.

This plugin works fine when connect to a github repository and installed through the netlify ui.

But, how can I use it deploy my site through the netlify cli?
Repository is not connected to github.

I would love an example or demonstration if possible.

Is it necessary to force `no-cache` for getServerSideProps?

https://github.com/netlify/next-on-netlify/blob/a73045f878b47f7fac8d70ceafd7e0ca39759d15/lib/templates/netlifyFunction.js#L29

It seems like the current code is forcing no-cache to be set on Netlify function calls (including getServerSideProps). I think this makes sense in a lot of cases, however we just had a use case where it would be safe to cache the results of that server-side execution for some period of time and we wanted to express that by setting the Cache-Control setting in the getServerSideProps method. This seems to be problematic because next-on-netlify adds an additional no-cache header which conflicts with ours. Is this something that could be conditional on an existence check for the header?

Plugin load if `next` is not available

next-on-netlify requires next as a peerDependency:

https://github.com/netlify/next-on-netlify/blob/7d1fd5e08969455035bf9918a6fb2d707984c4a1/package.json#L37-L39

This repository requires next-on-netlify as a production dependency:

https://github.com/netlify/netlify-plugin-nextjs/blob/ef4529016ed0f87ae89d5f312dc8f8f08d1ef7b6/package.json#L24-L29

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:

  • next and next-on-netlify should be require()'d only inside the if (isNextProject) { ... } block
  • _isNextProject() should try to require('next'), and return false if 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)?

Next.js version support

next-on-netlify requires users to install next themselves, i.e. it is a peerDependency.

https://github.com/netlify/next-on-netlify/blob/a48735f625cc7ad1a080b322673d3e9a11f42d27/package.json#L37-L39

Furthermore, it requires them to install a specific Next.js version (v9 even though v10 is the latest).

In this plugin, we are using the next package to load the configuration file

https://github.com/netlify/netlify-plugin-nextjs/blob/2849dc5f7c57e9fd827a939e067a871e4cb487b1/index.js#L7

https://github.com/netlify/netlify-plugin-nextjs/blob/2849dc5f7c57e9fd827a939e067a871e4cb487b1/package.json#L30

We might be missing a clear strategy on Next.js versioning compatibility:

  • When a new release of Next.js is made (e.g. Next 10), users of that new release would not be able to use it on both next-on-netlify and this plugin, because both are pinning a specific Next.js major version
  • Users with older Next.js versions (e.g. Next 8) might not be able to use both next-on-netlify and this plugin

As new versions of Next.js will be released, the lack of a clear strategy might become a bigger problem.

I would recommend the following:

  • Enforcing a minimum Next.js version with this plugin
  • Using a looser >= range for both this plugin and next-on-netlify in the peerDependency version range, so that we can support multiple Next.js major releases
  • Using the user's Next.js version to load the configuration file, i.e. making next a peerDependencies instead of a dependencies in this plugin's package.json
  • Ensure Next 10 is supported
  • When time comes to make this plugin opt-out instead of opt-in for all Netlify users, builds should check the site's Next.js version to ensure it is recent enough to use this plugin

What do you think?

Pin next-on-netlify version for releases

right now versions use @^x.x.x format, but that seems to be causing some issues. in future versions, we may want to consider using @x.x.x to avoid partial releases

Node 8 support

Our Node.js support is currently >=8.

This plugin is using fs.promises, which was introduced in Node 10. Using require('util').promisify(fs.appendFile) instead would make it work for Node 8 users.

Also, do you know whether next-on-netlify works on Node 8?

It'd be nice to add some engines.node like this. Our build system detects this property and prints a warning message when a site is using a Node.js version incompatible with a plugin.

Finally, our CI tests should run on Node 8 to ensure support.

Support for Yarn `portal` dependencies

Hi! I think the logic that detects whether next.js is installed should go through all the package.json's in a monorepo's packages.

For my project here, I'm using yarn v2 berry pnp to manage a monorepo. There are 2 packages:

  • packages/common, containing shared components.
  • packages/web, the app to build, depends on next.js and the above package via "@finance-apps/common": "portal:../common".

Here are my build settings:

Screen Shot 2021-01-12 at 12 01 09 PM

This doesn't work because the root package.json doesn't depend on next.js. Changing the base directory in Netlify to packages/web doesn't work because we need yarn 1 to install yarn 2, and yarn 1 doesn't recognize portal dependencies.

Support ES modules in `next.config.js`

ES modules are only supported in Node.js 12, and import() must be used instead of require().
We currently use require() because we support Node 10.

https://github.com/netlify/netlify-plugin-nextjs/blob/59ee2bbb2ffb971e964a07245eaa478ba1c07cbd/package.json#L55

It seems like some users are trying to use ES modules in their next.config.js, which currently fails.
Bugsnag errors here, here and there.

This will be a growing problem in 3 months (April 2021) when Node 10 becomes officially unsupported.

Fix `require('next')` when this plugin is pre-installed

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 doing require('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 locate next. In practice this would mean lines like:

const { PHASE_PRODUCTION_BUILD } = require('next/constants')

would be changed to:

const requirePeerDependency = function(modulePath) {
  if (process.env.NETLIFY === 'true') {
    return require(require.resolve(modulePath, { paths: ['.'] } }))
  }

  return require(modulePath)
}

const { PHASE_PRODUCTION_BUILD } = requirePeerDependency('next/constants')

This is hacky. This would need to be done in next-on-netlify too.

What do you think?

Support Next.js 10

Both this plugin and next-on-netlify should officially support Next.js 10.

If this is easy enough to do, we should run tests both on Next.js 9 and 10 too.

Getting error when using failback: 'blocking'

When I use fallback: 'blocking', deploy failed due to an error. This error seems to be in @netlify/plugin-nextjs.
If I just set fallback parameter to 'false', there is no issue and deploy is successful.
This value blocking has been supported from Next.js 10.

Logs on the deploy log were here.

10:30:59 PM: ────────────────────────────────────────────────────────────────
10:30:59 PM:   Plugin "@netlify/plugin-nextjs" internal error                
10:30:59 PM: ────────────────────────────────────────────────────────────────
10:30:59 PM: ​
10:30:59 PM:   Error message
10:30:59 PM:   Error: 'netlify-automatic-functions/next_posts_id/next_posts_id.js' already exists
10:30:59 PM: ​
10:30:59 PM:   Plugin details
10:30:59 PM:   Package:        @netlify/plugin-nextjs
10:30:59 PM:   Version:        1.0.2
10:30:59 PM:   Repository:     git+https://github.com/netlify/netlify-plugin-nextjs.git
10:30:59 PM:   npm link:       https://www.npmjs.com/package/@netlify/plugin-nextjs
10:30:59 PM:   Report issues:  https://github.com/netlify/netlify-plugin-nextjs/issues
10:30:59 PM: ​
10:30:59 PM:   Error location
10:30:59 PM:   In "onBuild" event in "@netlify/plugin-nextjs" from Netlify app
10:30:59 PM:       at mayCopyFile (/opt/buildhome/.netlify-build-plugins/node_modules/fs-extra/lib/copy-sync/copy-sync.js:62:11)
10:30:59 PM:       at onFile (/opt/buildhome/.netlify-build-plugins/node_modules/fs-extra/lib/copy-sync/copy-sync.js:54:10)
10:30:59 PM:       at getStats (/opt/buildhome/.netlify-build-plugins/node_modules/fs-extra/lib/copy-sync/copy-sync.js:48:44)
10:30:59 PM:       at startCopy (/opt/buildhome/.netlify-build-plugins/node_modules/fs-extra/lib/copy-sync/copy-sync.js:38:10)
10:30:59 PM:       at handleFilterAndCopy (/opt/buildhome/.netlify-build-plugins/node_modules/fs-extra/lib/copy-sync/copy-sync.js:33:10)
10:30:59 PM:       at copySync (/opt/buildhome/.netlify-build-plugins/node_modules/fs-extra/lib/copy-sync/copy-sync.js:26:10)
10:30:59 PM:       at setupNetlifyFunctionForPage (/opt/buildhome/.netlify-build-plugins/node_modules/next-on-netlify/lib/helpers/setupNetlifyFunctionForPage.js:21:3)
10:30:59 PM:       at /opt/buildhome/.netlify-build-plugins/node_modules/next-on-netlify/lib/pages/getStaticPropsWithFallback/setup.js:20:5
10:30:59 PM:       at Array.forEach (<anonymous>)
10:30:59 PM:       at setup (/opt/buildhome/.netlify-build-plugins/node_modules/next-on-netlify/lib/pages/getStaticPropsWithFallback/setup.js:16:9)

Builds error when using next's i18n due to lack of `serverless/pages/index.html` file

I'm trying to move a Next.js site (which uses next's i18n routing) over to Netlify, but sadly can't due to this error:

Error: ENOENT: no such file or directory, stat '.next/serverless/pages/index.html'

It's true that this file doesn't exist. Instead, the default homepage can be found at '.next/serverless/pages/en/index.html' (replacing "en" with whatever default locale is set in next.config.js).

It would be great to detect if i18n is in use, and then get the homepage's file location by reading the default locale.

Support `next.config.js` in parent directories

In a monorepo setup, it is possible that next.config.js might be in a parent directory if the user has set a base directory.
Next.js is searching next.config.js in parent directories using find-up:

https://github.com/vercel/next.js/blob/497cac4b93de9ecf6c7ed79bd6557dcd3bb51be5/packages/next/next-server/server/config.ts#L450

However we are not currently searching it in parent directories:

https://github.com/netlify/netlify-plugin-nextjs/blob/2849dc5f7c57e9fd827a939e067a871e4cb487b1/index.js#L57

Using find-up should fix this bug.

Cannot find module '_process' from generated next_blog.js

I have spent a great deal of time trying to figure out why I'm getting the error below. It's clear that the '_process' module that's missing is being required by a generated function to get the next blog post of my netlify/next app (using this plugin of course). I could be mistaken but I believe it's this plugin (or something higher up in the netlify build?) that's generating these files (screenshot below). I've scoured docs and have tried to mess around with directory structures, configurations, etc. but cannot figure out why this module is being required by these generated files w/out it being accessible. Of course, I tried to install _process via yarn but no dice there either. Any suggestions here would be greatly appreciated. Thanks for all the awesome work you all do!

  Dependencies installation error                               
────────────────────────────────────────────────────────────────

  Error message
  A Netlify Function failed to require one of its dependencies.
  If the dependency is a Node module, please make sure it is present in the site's top-level "package.json".
  If it is a local file instead, please make sure the file exists and its filename is correctly spelled.

  In file "/home/thislogancall/code/next-netlify-project/.netlify/functions/next_blog/next_blog.js"
  Cannot find module '_process'
  Require stack:
  - /home/thislogancall/code/next-netlify-project/node_modules/@netlify/zip-it-and-ship-it/src/node_dependencies/resolve.js
  - /home/thislogancall/code/next-netlify-project/node_modules/@netlify/zip-it-and-ship-it/src/node_dependencies/index.js
  - /home/thislogancall/code/next-netlify-project/node_modules/@netlify/zip-it-and-ship-it/src/main.js
  - /home/thislogancall/code/next-netlify-project/node_modules/@netlify/build/src/plugins_core/functions/index.js
  - /home/thislogancall/code/next-netlify-project/node_modules/@netlify/build/src/commands/get.js
  - /home/thislogancall/code/next-netlify-project/node_modules/@netlify/build/src/core/main.js
  - /home/thislogancall/code/next-netlify-project/node_modules/netlify-cli/src/lib/build.js
  - /home/thislogancall/code/next-netlify-project/node_modules/netlify-cli/src/commands/build/index.js
  - /home/thislogancall/code/next-netlify-project/node_modules/@oclif/config/lib/plugin.js
  - /home/thislogancall/code/next-netlify-project/node_modules/@oclif/config/lib/config.js
  - /home/thislogancall/code/next-netlify-project/node_modules/@oclif/config/lib/index.js
  - /home/thislogancall/code/next-netlify-project/node_modules/@oclif/command/lib/command.js
  - /home/thislogancall/code/next-netlify-project/node_modules/@oclif/command/lib/index.js
  - /home/thislogancall/code/next-netlify-project/node_modules/netlify-cli/src/index.js
  - /home/thislogancall/code/next-netlify-project/node_modules/netlify-cli/bin/run

  Resolved config
  build:
    command: yarn run create
    commandOrigin: config
    functions: /home/thislogancall/code/next-netlify-project/.netlify/functions
    publish: /home/thislogancall/code/next-netlify-project/dist
  plugins:
    - inputs: {}
      origin: config
      package: '@netlify/plugin-nextjs'
error Command failed with exit code 2.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Directory structure:

image

Dependency version:

    "netlify-lambda": "^2.0.3",
    "next": "^9.5.3",
    "next-transpile-modules": "^4.1.0",
    "react": "^17.0.1",
    "react-dom": "^17.0.1",
    "@netlify/plugin-nextjs": "^2.0.0",
    "netlify-cli": "^3.4.7",

Babel config:

{
  "presets": [
    "@babel/preset-env",
    "next/babel"
  ],
  "retainLines": true,
  "env": {
    "production": {
      "plugins": [
        [
          "@babel/plugin-transform-regenerator",
          {
            "asyncGenerators": true,
            "generators": true,
            "async": true
          }
        ],
        [
          "@emotion/babel-plugin",
          {
            "hoist": true
          }
        ]
      ]
    },
    "development": {
      "plugins": [
        [
          "@babel/plugin-transform-regenerator",
          {
            "asyncGenerators": true,
            "generators": true,
            "async": true
          }
        ],
        [
          "@emotion/babel-plugin",
          {
            "sourceMap": true
          }
        ]
      ]
    }
  }
}

Windows support

We should run CI tests on Windows and macOS as well, to ensure this plugin works for Netlify CLI users who run netlify build.

Many of our CLI users are on Windows (example for next-on-netlify).

Missing `require()` in `next.config.js`

This error seems to happen frequently in production.

Looking into individual instances of it, it seems like this happens when the site's next.config.js includes a require() statement towards a dependency that is not installed in package.json, or when there is a typo in the required path.

This is a user error. However, I wanted to report this in case there was a reason why this user error seems to be so frequent. I am wondering whether this is normal for so many sites seem to have invalid next.config.js?

Handle errors when loading `next.config.js`

There are many reasons why loading next.config.js might fail such as:

  • Invalid configuration value (example)
  • Syntax error (example)
  • General error in the JavaScript logic, throwing an exception (example)

Those errors are currently reported as plugin bugs. We should report those as user errors instead by adding a try/catch + utils.build.failBuild() block.

Cache `.next/cache/` between builds

We could use the cache utility to cache .next/cache between builds, to speed up Next.js builds.

An existing plugin is already doing it (source code). Since that plugin allows users to customize the path to .next/cache/, it could still be useful for the few users who need that. @lindsaylevine Do you think using a custom file path for .next/ is common?

Without that case in mind, adding this would probably look like this:

const CACHE_DIR = '.next/cache/'
const BUILD_MANIFEST = '.next/build-manifest.json'

module.exports = {
	async onPreBuild({ utils }) {
		if (await utils.cache.restore(CACHE_DIR)) {
			console.log('Next.js cache restored.')
		} else {
			console.log('No Next.js cache to restore')
		}
	},
	async onPostBuild({ utils }) {
		if (await utils.cache.save(CACHE_DIR, { digests: [BUILD_MANIFEST] })) {
			console.log('Next.js cache saved.')
		} else {
			console.log('No Next.js cache to save.')
		}
	}
}

What do you think?

Deploy failed due to an error in @netlify/plugin-deploy-core plugin

Screen Shot 2021-01-22 at 12 05 03 PM

7:53:32 PM: Build ready to start
7:53:33 PM: build-image version: d84c79427e8f83c1ba17bcdd7b3fe38059376b68
7:53:33 PM: build-image tag: v3.6.1
7:53:33 PM: buildbot version: 734b021f1afb208e332629f2580fef69fda9a3bc
7:53:34 PM: Fetching cached dependencies
7:53:34 PM: Starting to download cache of 297.6MB
7:53:40 PM: Finished downloading cache in 6.411431228s
7:53:40 PM: Starting to extract cache
7:53:52 PM: Finished extracting cache in 11.687595739s
7:53:52 PM: Finished fetching cache in 18.203333406s
7:53:52 PM: Starting to prepare the repo for build
7:53:52 PM: Preparing Git Reference pull/50/head
7:53:54 PM: Starting build script
7:53:54 PM: Installing dependencies
7:53:54 PM: Python version set to 2.7
7:53:55 PM: Started restoring cached node version
7:53:57 PM: Finished restoring cached node version
7:53:58 PM: v12.18.0 is already installed.
7:53:59 PM: Now using node v12.18.0 (npm v6.14.4)
7:53:59 PM: Started restoring cached build plugins
7:53:59 PM: Finished restoring cached build plugins
7:53:59 PM: Attempting ruby version 2.7.1, read from environment
7:54:00 PM: Using ruby version 2.7.1
7:54:01 PM: Using PHP version 5.6
7:54:01 PM: Started restoring cached node modules
7:54:01 PM: Finished restoring cached node modules
7:54:01 PM: Started restoring cached yarn cache
7:54:01 PM: Finished restoring cached yarn cache
7:54:01 PM: Installing NPM modules using Yarn version 1.22.4
7:54:02 PM: yarn install v1.22.4
7:54:02 PM: [1/4] Resolving packages...
7:54:02 PM: [2/4] Fetching packages...
7:54:30 PM: info [email protected]: The platform "linux" is incompatible with this module.
7:54:30 PM: info "[email protected]" is an optional dependency and failed compatibility check. Excluding it from installation.
7:54:30 PM: info [email protected]: The platform "linux" is incompatible with this module.
7:54:30 PM: info "[email protected]" is an optional dependency and failed compatibility check. Excluding it from installation.
7:54:30 PM: info [email protected]: The platform "linux" is incompatible with this module.
7:54:30 PM: info "[email protected]" is an optional dependency and failed compatibility check. Excluding it from installation.
7:54:30 PM: [3/4] Linking dependencies...
7:54:30 PM: warning " > [email protected]" has unmet peer dependency "prop-types@^15.x".
7:54:30 PM: warning "bible-reference-rcl > [email protected]" has unmet peer dependency "react-is@>= 16.8.0".
7:54:30 PM: warning " > [email protected]" has incorrect peer dependency "react@^16.8.6".
7:54:30 PM: warning " > [email protected]" has incorrect peer dependency "react-dom@^16.8.6".
7:54:30 PM: warning "gitea-react-toolkit > [email protected]" has incorrect peer dependency "react@^16.8.6".
7:54:30 PM: warning "gitea-react-toolkit > [email protected]" has incorrect peer dependency "react-dom@^16.8.6".
7:54:30 PM: warning "markdown-translatable > [email protected]" has incorrect peer dependency "react@^15.0.0 || ^16.0.0".
7:54:30 PM: warning " > [email protected]" has incorrect peer dependency "react@^16.8.6".
7:54:30 PM: warning " > [email protected]" has incorrect peer dependency "react-dom@^16.8.6".
7:54:30 PM: warning "resource-workspace-rcl > react-grid-layout > [email protected]" has incorrect peer dependency "[email protected] || 15.x || 16.x".
7:54:30 PM: warning "resource-workspace-rcl > react-grid-layout > [email protected]" has incorrect peer dependency "[email protected] || 15.x || 16.x".
7:54:30 PM: warning " > [email protected]" has unmet peer dependency "@material-ui/styles@^4.4.1".
7:54:30 PM: warning " > [email protected]" has incorrect peer dependency "react@^16.13.1".
7:54:30 PM: warning " > [email protected]" has incorrect peer dependency "react-dom@^16.13.1".
7:54:30 PM: warning "scripture-resources-rcl > [email protected]" has incorrect peer dependency "react@^16.8.6".
7:54:30 PM: warning "scripture-resources-rcl > [email protected]" has incorrect peer dependency "react-dom@^16.8.6".
7:54:30 PM: warning "scripture-resources-rcl > [email protected]" has incorrect peer dependency "react@^15.3.0 || ^16.0.0".
7:54:30 PM: warning "scripture-resources-rcl > gitea-react-toolkit > [email protected]" has unmet peer dependency "node@^10.23.0".
7:54:30 PM: warning "scripture-resources-rcl > gitea-react-toolkit > react-json-view > [email protected]" has incorrect peer dependency "react@^15.0.2 || ^16.0.0-beta || ^16.0.0".
7:54:30 PM: warning "scripture-resources-rcl > gitea-react-toolkit > react-json-view > [email protected]" has incorrect peer dependency "react@>=0.14.0 <17.0.0".
7:54:30 PM: warning " > [email protected]" has incorrect peer dependency "@material-ui/[email protected]".
7:54:30 PM: warning " > [email protected]" has incorrect peer dependency "@material-ui/[email protected]".
7:54:30 PM: warning " > [email protected]" has unmet peer dependency "prop-types@^15.x".
7:54:30 PM: warning "single-scripture-rcl > [email protected]" has unmet peer dependency "webpack@^4.0.0 || ^5.0.0".
7:54:30 PM: warning "single-scripture-rcl > [email protected]" has unmet peer dependency "webpack@*".
7:54:30 PM: warning "single-scripture-rcl > [email protected]" has unmet peer dependency "usfm-js@^2.1.0".
7:54:30 PM: warning " > [email protected]" has incorrect peer dependency "@material-ui/lab@^4.x".
7:54:30 PM: warning " > [email protected]" has unmet peer dependency "prop-types@^15.x".
7:54:30 PM: warning " > [email protected]" has incorrect peer dependency "scripture-resources-rcl@^2.x".
7:54:46 PM: [4/4] Building fresh packages...
7:54:49 PM: Done in 47.37s.
7:54:49 PM: NPM modules installed using Yarn
7:54:49 PM: Started restoring cached go cache
7:54:49 PM: Finished restoring cached go cache
7:54:49 PM: go version go1.14.4 linux/amd64
7:54:49 PM: go version go1.14.4 linux/amd64
7:54:49 PM: Installing missing commands
7:54:49 PM: Verify run directory
7:54:51 PM: ​
7:54:51 PM: ────────────────────────────────────────────────────────────────
7:54:51 PM:   Netlify Build                                                 
7:54:51 PM: ────────────────────────────────────────────────────────────────
7:54:51 PM: ​
7:54:51 PM: ❯ Version
7:54:51 PM:   @netlify/build 8.1.0
7:54:51 PM: ​
7:54:51 PM: ❯ Flags
7:54:51 PM:   deployId: 600a220c8d0b870007e39e8b
7:54:51 PM:   mode: buildbot
7:54:51 PM: ​
7:54:51 PM: ❯ Current directory
7:54:51 PM:   /opt/build/repo
7:54:51 PM: ​
7:54:51 PM: ❯ Config file
7:54:51 PM:   /opt/build/repo/netlify.toml
7:54:51 PM: ​
7:54:51 PM: ❯ Context
7:54:51 PM:   deploy-preview
7:54:51 PM: ​
7:54:51 PM: ❯ Installing plugins
7:54:51 PM:    - @netlify/[email protected]
7:55:08 PM: ​
7:55:08 PM: ❯ Loading plugins
7:55:08 PM:    - [email protected] from Netlify app
7:55:08 PM:    - @netlify/[email protected] from netlify.toml
7:55:10 PM: ​
7:55:10 PM: ────────────────────────────────────────────────────────────────
7:55:10 PM:   1. onPreBuild command from netlify-plugin-cache-nextjs        
7:55:10 PM: ────────────────────────────────────────────────────────────────
7:55:10 PM: ​
7:55:10 PM: Restored the cached .next folder at the location `.next/cache`
7:55:10 PM: ​
7:55:10 PM: (netlify-plugin-cache-nextjs onPreBuild completed in 618ms)
7:55:10 PM: ​
7:55:10 PM: ────────────────────────────────────────────────────────────────
7:55:10 PM:   2. onPreBuild command from @netlify/plugin-nextjs             
7:55:10 PM: ────────────────────────────────────────────────────────────────
7:55:10 PM: ​
7:55:10 PM: ** Warning: support for Next.js >=10.0.0 is experimental **
7:55:10 PM: ​
7:55:10 PM: (@netlify/plugin-nextjs onPreBuild completed in 29ms)
7:55:10 PM: ​
7:55:10 PM: ────────────────────────────────────────────────────────────────
7:55:10 PM:   3. build.command from netlify.toml                            
7:55:10 PM: ────────────────────────────────────────────────────────────────
7:55:10 PM: ​
7:55:10 PM: $ npm run build
7:55:10 PM: > [email protected] build /opt/build/repo
7:55:10 PM: > next build
7:55:11 PM: info  - Creating an optimized production build...
7:56:46 PM: warn  - Compiled with warnings
7:56:46 PM: ./node_modules/next/dist/next-server/server/load-components.js
7:56:46 PM: Critical dependency: the request of a dependency is an expression
7:56:46 PM: ./node_modules/next/dist/next-server/server/load-components.js
7:56:46 PM: Critical dependency: the request of a dependency is an expression
7:56:46 PM: ./node_modules/next/dist/next-server/server/require.js
7:56:46 PM: Critical dependency: the request of a dependency is an expression
7:56:46 PM: ./node_modules/next/dist/next-server/server/require.js
7:56:46 PM: Critical dependency: the request of a dependency is an expression
7:56:46 PM: ./node_modules/next/dist/next-server/server/require.js
7:56:46 PM: Critical dependency: the request of a dependency is an expression
7:56:46 PM: ./node_modules/ws/lib/buffer-util.js
7:56:46 PM: Module not found: Can't resolve 'bufferutil' in '/opt/build/repo/node_modules/ws/lib'
7:56:46 PM: ./node_modules/ws/lib/validation.js
7:56:46 PM: Module not found: Can't resolve 'utf-8-validate' in '/opt/build/repo/node_modules/ws/lib'
7:56:46 PM: info  - Collecting page data...
7:56:57 PM: info  - Generating static pages (0/4)
7:57:01 PM: info  - Generating static pages (1/4)
7:57:03 PM: info  - Generating static pages (2/4)
7:57:03 PM: info  - Generating static pages (3/4)
7:57:03 PM: info  - Generating static pages (4/4)
7:57:03 PM: info  - Finalizing page optimization...
7:57:03 PM: Page                                                           Size     First Load JS
7:57:03 PM: ┌ ○ /                                                          403 B          1.91 MB
7:57:03 PM: ├   /_app                                                      0 B            1.13 MB
7:57:03 PM: ├ ○ /404                                                       2.97 kB        1.14 MB
7:57:03 PM: ├ λ /api/feedback                                              0 B            1.13 MB
7:57:03 PM: ├ ○ /feedback                                                  1.2 kB         1.91 MB
7:57:03 PM: └ ○ /settings                                                  360 kB         2.27 MB
7:57:03 PM: + First Load JS shared by all                                  1.13 MB
7:57:03 PM:   ├ chunks/a00da3a2.837d6d.js                                  16.9 kB
7:57:03 PM:   ├ chunks/commons.711159.js                                   12.8 kB
7:57:03 PM:   ├ chunks/dcdeed2c.7dc68c.js                                  68.8 kB
7:57:03 PM:   ├ chunks/f9d8d449643ab024fd52c56515a34f167733efc5.3c5cce.js  981 kB
7:57:03 PM:   ├ chunks/framework.fd282e.js                                 42.3 kB
7:57:03 PM:   ├ chunks/main.2b4e35.js                                      6.55 kB
7:57:03 PM:   ├ chunks/pages/_app.dd2e29.js                                3.02 kB
7:57:03 PM:   ├ chunks/webpack.94d6c7.js                                   1.26 kB
7:57:03 PM:   └ css/eec78965a83a2709f70c.css                               2.05 kB
7:57:03 PM: λ  (Lambda)  server-side renders at runtime (uses getInitialProps or getServerSideProps)
7:57:03 PM: ○  (Static)  automatically rendered as static HTML (uses no initial props)
7:57:03 PM: ●  (SSG)     automatically generated as static HTML + JSON (uses getStaticProps)
7:57:03 PM:    (ISR)     incremental static regeneration (uses revalidate in getStaticProps)
7:57:04 PM: ​
7:57:04 PM: (build.command completed in 1m 53.5s)
7:57:04 PM: ​
7:57:04 PM: ────────────────────────────────────────────────────────────────
7:57:04 PM:   4. onBuild command from @netlify/plugin-nextjs                
7:57:04 PM: ────────────────────────────────────────────────────────────────
7:57:04 PM: ​
7:57:04 PM: ** Running Next on Netlify package **
7:57:04 PM: 🚀 Next on Netlify 🚀
7:57:04 PM: 🌍️ Copying public/ folder to /opt/build/repo
7:57:04 PM: 💼 Copying static NextJS assets to /opt/build/repo
7:57:04 PM: 💫 Setting up API endpoints as Netlify Functions in netlify-automatic-functions
7:57:04 PM: 💫 Setting up pages with getInitialProps as Netlify Functions in netlify-automatic-functions
7:57:04 PM: 💫 Setting up pages with getServerSideProps as Netlify Functions in netlify-automatic-functions
7:57:04 PM: 🔥 Copying pre-rendered pages with getStaticProps and JSON data to /opt/build/repo
7:57:04 PM: 💫 Setting up pages with getStaticProps and fallback: true as Netlify Functions in netlify-automatic-functions
7:57:04 PM: 💫 Setting up pages with getStaticProps and revalidation interval as Netlify Functions in netlify-automatic-functions
7:57:04 PM: 🔥 Copying pre-rendered pages without props to /opt/build/repo
7:57:04 PM: 🔀 Setting up redirects
7:57:04 PM: 🔀 Setting up headers
7:57:04 PM: ​
7:57:04 PM: (@netlify/plugin-nextjs onBuild completed in 104ms)
7:57:04 PM: ​
7:57:04 PM: ────────────────────────────────────────────────────────────────
7:57:04 PM:   5. Functions bundling                                         
7:57:04 PM: ────────────────────────────────────────────────────────────────
7:57:04 PM: ​
7:57:04 PM: Packaging Functions from netlify-automatic-functions directory:
7:57:04 PM:  - next_api_feedback/next_api_feedback.js
7:57:06 PM: ​
7:57:06 PM: (Functions bundling completed in 2.2s)
7:57:06 PM: ​
7:57:06 PM: ────────────────────────────────────────────────────────────────
7:57:06 PM:   6. onPostBuild command from netlify-plugin-cache-nextjs       
7:57:06 PM: ────────────────────────────────────────────────────────────────
7:57:06 PM: ​
7:57:07 PM: Cached the .next folder at the location `.next/cache`
7:57:07 PM: ​
7:57:07 PM: (netlify-plugin-cache-nextjs onPostBuild completed in 824ms)
7:57:07 PM: ​
7:57:07 PM: ────────────────────────────────────────────────────────────────
7:57:07 PM:   7. onPostBuild command from @netlify/plugin-deploy-core       
7:57:07 PM: ────────────────────────────────────────────────────────────────
7:57:07 PM: ​
7:57:07 PM: Starting to deploy site from ''
7:57:10 PM: ​
7:57:10 PM: ────────────────────────────────────────────────────────────────
7:57:10 PM:   Plugin "@netlify/plugin-deploy-core" failed                   
7:57:10 PM: ────────────────────────────────────────────────────────────────
7:57:10 PM: ​
7:57:10 PM:   Error message
7:57:10 PM:   Error: Deploy did not succeed: Invalid filename 'node_modules/es5-ext/test/string/#/starts-with/shim.js'. Deployed filenames cannot contain # or ? characters
7:57:10 PM: ​
7:57:10 PM:   Plugin details
7:57:10 PM:   Package:        @netlify/plugin-deploy-core
7:57:10 PM:   Version:        8.1.0
7:57:10 PM:   Repository:     git+https://github.com/netlify/build.git
7:57:10 PM:   npm link:       https://www.npmjs.com/package/@netlify/build
7:57:10 PM:   Report issues:  https://github.com/netlify/build/issues
7:57:10 PM: ​
7:57:10 PM:   Error location
7:57:10 PM:   In "onPostBuild" event in "@netlify/plugin-deploy-core" from core
7:57:10 PM: ​
7:57:10 PM:   Resolved config
7:57:10 PM:   build:
7:57:10 PM:     command: npm run build
7:57:10 PM:     commandOrigin: config
7:57:10 PM:     environment:
7:57:10 PM:       - HELP_DESK_EMAIL
7:57:10 PM:       - HELP_DESK_TOKEN
7:57:10 PM:       - REVIEW_ID
7:57:10 PM:   plugins:
7:57:10 PM:     - inputs: {}
7:57:10 PM:       origin: ui
7:57:10 PM:       package: netlify-plugin-cache-nextjs
7:57:10 PM:     - inputs: {}
7:57:10 PM:       origin: config
7:57:10 PM:       package: '@netlify/plugin-nextjs'
7:57:10 PM: Caching artifacts
7:57:10 PM: Started saving node modules
7:57:10 PM: Finished saving node modules
7:57:10 PM: Started saving build plugins
7:57:10 PM: Finished saving build plugins
7:57:10 PM: Started saving yarn cache
7:57:10 PM: Finished saving yarn cache
7:57:10 PM: Started saving pip cache
7:57:10 PM: Finished saving pip cache
7:57:10 PM: Started saving emacs cask dependencies
7:57:10 PM: Finished saving emacs cask dependencies
7:57:10 PM: Started saving maven dependencies
7:57:10 PM: Finished saving maven dependencies
7:57:10 PM: Started saving boot dependencies
7:57:10 PM: Finished saving boot dependencies
7:57:10 PM: Started saving rust rustup cache
7:57:10 PM: Finished saving rust rustup cache
7:57:10 PM: Started saving go dependencies
7:57:10 PM: Finished saving go dependencies
7:57:10 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
7:57:10 PM: Failing build: Failed to build site
7:57:10 PM: Failed during stage 'building site': Build script returned non-zero exit code: 2
7:57:10 PM: Finished processing build request in 3m36.987204584s

Do not configure to set `build.command`, `build.functions` and `build.publish`

In order to use this plugin, users have to set build.command, build.functions and build.publish in their netlify.toml.

We should instead re-use the configuration properties set the site:

  • If build.functions is defined, we should use this. If not, we should default to the default functions directory. This value can be retrieved using constants.FUNCTIONS_SRC (see #11)
  • Same for build.publish. This value can be retrieved using constants.PUBLISH_DIR.
  • The main reason we require setting build.command seem to be to ensure that next-on-netlify is run after next build. This should already be covered by this plugin considering it calls next-on-netlify programmatically during onPostBuild.

This would require updating next-on-netlify so it accepts custom functions and publish directories.

The main pros would be:

  • This allows users to define custom functions and publish directories
  • This removes those configuration steps, so we can eventually provide a 0-steps use of this plugin

[next-auth][error][adapter_connection_error] DriverPackageNotInstalledError

Describe the bug
Please include a repo to reproduce your issue if you can!

To Reproduce
Issue: incorrect or missing library. Build/deploy is successful. The issue occurs on calling the api function.

Technical reason: Next-auth peer dependency is typeorm in latest aka buggy version.

Workaround: Force typeorm version via “resolutions” setting in package.json.

Probably cause: Resolutions form package.json are ignored.

Result on netlify - see the error log below.

Result on local env, Vercel - works with resolutions hack.

9:38:36 AM: 2020-12-28T08:38:36.854Z	0ea89e82-cf68-4a93-9678-222cc57f7acc	ERROR	[next-auth][error][adapter_connection_error] DriverPackageNotInstalledError: MongoDB package has not been found installed. Try to install it: npm install mongodb --save
    at new DriverPackageNotInstalledError (/var/task/src/node_modules/typeorm/error/DriverPackageNotInstalledError.js:10:28)
    at MongoDriver.loadDependencies (/var/task/src/node_modules/typeorm/driver/mongodb/MongoDriver.js:325:19)
    at new MongoDriver (/var/task/src/node_modules/typeorm/driver/mongodb/MongoDriver.js:139:14)
    at DriverFactory.create (/var/task/src/node_modules/typeorm/driver/DriverFactory.js:48:24)
    at new Connection (/var/task/src/node_modules/typeorm/connection/Connection.js:56:59)
    at ConnectionManager.create (/var/task/src/node_modules/typeorm/connection/ConnectionManager.js:56:26)
    at /var/task/src/node_modules/typeorm/index.js:196:66
    at step (/var/task/src/node_modules/tslib/tslib.js:141:27)
    at Object.next (/var/task/src/node_modules/tslib/tslib.js:122:57)
    at /var/task/src/node_modules/tslib/tslib.js:115:75 
https://next-auth.js.org/errors#adapter_connection_error
9:38:36 AM: 2020-12-28T08:38:36.854Z	0ea89e82-cf68-4a93-9678-222cc57f7acc	ERROR	[next-auth][error][oauth_callback_handler_error] TypeError: Cannot destructure property 'manager' of 'connection' as it is null.
    at Object.<anonymous> (/var/task/src/node_modules/next-auth/dist/adapters/typeorm/index.js:102:9)
    at Generator.next (<anonymous>)
    at asyncGeneratorStep (/var/task/src/node_modules/next-auth/dist/adapters/typeorm/index.js:28:103)
    at _next (/var/task/src/node_modules/next-auth/dist/adapters/typeorm/index.js:30:194)
    at processTicksAndRejections (internal/process/task_queues.js:97:5) 
{
  "name": "test-app",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "dev": "next dev",
    "start": "next start",
    "build": "next build",
    "export": "next export",
    "postbuild": "next-on-netlify",
    "test": "jest"
  },
  "resolutions": {
    "typeorm": "0.2.24"
  },
  "dependencies": {
    "aws-sdk": "^2.809.0",
    "axios": "^0.21.0",
    "bcrypt": "^5.0.0",
    "bootstrap": "^4.5.3",
    "date-fns": "^2.11.1",
    "faunadb": "^4.0.0",
    "fs-extra": "^9.0.1",
    "gray-matter": "^4.0.2",
    "local-storage": "^2.0.0",
    "mongodb": "^3.6.3",
    "next-auth": "^3.1.0",
    "object-hash": "^2.0.3",
    "qrcode": "^1.4.4",
    "react": "16.13.1",
    "react-bootstrap": "^1.4.0",
    "react-dom": "16.13.1",
    "react-icons": "^3.11.0",
    "react-scroll": "^1.8.1",
    "react-textarea-autosize": "^8.3.0",
    "reflect-metadata": "^0.1.13",
    "remark": "^12.0.0",
    "remark-html": "^12.0.0",
    "uuid": "^8.3.2",
    "yup": "0.31.1"
  },
  "devDependencies": {
    "@babel/core": "^7.12.9",
    "@babel/plugin-proposal-decorators": "^7.12.1",
    "@types/bcrypt": "^3.0.0",
    "@types/fs-extra": "^9.0.4",
    "@types/jest": "^26.0.18",
    "@types/next-auth": "^3.1.18",
    "@types/node": "^14.14.9",
    "@types/object-hash": "^1.3.4",
    "@types/qrcode": "^1.3.5",
    "@types/react": "^17.0.0",
    "@types/react-scroll": "^1.8.2",
    "@types/sass": "^1.16.0",
    "@types/uuid": "^8.3.0",
    "@types/yup": "^0.29.10",
    "babel-jest": "^26.6.3",
    "dotenv-expand": "^5.1.0",
    "identity-obj-proxy": "^3.0.0",
    "jest": "^26.6.3",
    "jest-css-modules-transform": "^4.1.0",
    "jest-dom": "^4.0.0",
    "netlify-plugin-cache-nextjs": "^1.5.2",
    "next": "9.5.5",
    "next-on-netlify": "^2.6.3",
    "sass": "^1.30.0",
    "ts-node": "^9.1.0",
    "typescript": "^4.1.2"
  }
}

Versions

  • Next: "9.5.3"
  • next-on-netlify: "^2.6.3"

Initially posted on: https://community.netlify.com/t/driverpackagenotinstallederror/29063

Markdown files cannot be found in netlify function environment

Hi. First of all, Thanks for the plugin.

I am getting errors with my markdown blog. Pages and components seem to be working perfectly (tested with sample). but not working with the markdown directory. It's giving me an error related to my file location.

{
"errorType": "Runtime.UnhandledPromiseRejection",
"errorMessage": "Error: ENOENT: no such file or directory, scandir '/var/task/contents/blog'",
"trace": [
"Runtime.UnhandledPromiseRejection: Error: ENOENT: no such file or directory, scandir '/var/task/contents/blog'",
"    at process.<anonymous> (/var/runtime/index.js:35:15)",
"    at process.emit (events.js:314:20)",
"    at processPromiseRejections (internal/process/promises.js:209:33)",
"    at processTicksAndRejections (internal/process/task_queues.js:98:32)"
]
}

Deploy Log

5:36:18 PM: Build ready to start
5:36:20 PM: build-image version: 53b83b6bede2920f236b25b6f5a95334320dc849
5:36:20 PM: build-image tag: v3.6.0
5:36:20 PM: buildbot version: 94ed42511c4e70547a960237db686b74875fef2d
5:36:20 PM: Fetching cached dependencies
5:36:20 PM: Starting to download cache of 275.3KB
5:36:20 PM: Finished downloading cache in 77.823649ms
5:36:20 PM: Starting to extract cache
5:36:20 PM: Finished extracting cache in 14.676215ms
5:36:20 PM: Finished fetching cache in 92.929933ms
5:36:20 PM: Starting to prepare the repo for build
5:36:21 PM: Preparing Git Reference refs/heads/main
5:36:23 PM: Starting build script
5:36:23 PM: Installing dependencies
5:36:23 PM: Python version set to 2.7
5:36:24 PM: v12.18.0 is already installed.
5:36:25 PM: Now using node v12.18.0 (npm v6.14.4)
5:36:25 PM: Started restoring cached build plugins
5:36:25 PM: Finished restoring cached build plugins
5:36:25 PM: Attempting ruby version 2.7.1, read from environment
5:36:27 PM: Using ruby version 2.7.1
5:36:27 PM: Using PHP version 5.6
5:36:27 PM: Started restoring cached node modules
5:36:27 PM: Finished restoring cached node modules
5:36:27 PM: Started restoring cached yarn cache
5:36:27 PM: Finished restoring cached yarn cache
5:36:27 PM: Installing yarn at version 1.22.4
5:36:27 PM: Installing Yarn!
5:36:27 PM: > Downloading tarball...
5:36:27 PM: [1/2]: https://yarnpkg.com/downloads/1.22.4/yarn-v1.22.4.tar.gz --> /tmp/yarn.tar.gz.OaqmPaAqag
5:36:27 PM:   % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
5:36:27 PM:                                  Dload  Upload   Total   Spent    Left  Speed
5:36:28 PM:   0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
5:36:28 PM: 100    80  100    80    0     0    241      0 --:--:-- --:--:-- --:--:--   241
5:36:28 PM:   0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
5:36:28 PM: 100    93  100    93    0     0    138      0 --:--:-- --:--:-- --:--:--  3444
5:36:28 PM: 100   643  100   643    0     0    620      0  0:00:01  0:00:01 --:--:--   620
5:36:29 PM: 100 1215k  100 1215k    0     0   802k      0  0:00:01  0:00:01 --:--:--  802k
5:36:29 PM: [2/2]: https://yarnpkg.com/downloads/1.22.4/yarn-v1.22.4.tar.gz.asc --> /tmp/yarn.tar.gz.OaqmPaAqag.asc
5:36:29 PM: 100    84  100    84    0     0   3073      0 --:--:-- --:--:-- --:--:--  3073
5:36:29 PM: 100    97  100    97    0     0   1764      0 --:--:-- --:--:-- --:--:--  1764
5:36:29 PM:   0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
5:36:29 PM: 100   647  100   647    0     0   3829      0 --:--:-- --:--:-- --:--:--  631k
5:36:29 PM: 100  1028  100  1028    0     0   4923      0 --:--:-- --:--:-- --:--:--  4923
5:36:29 PM: > Verifying integrity...
5:36:29 PM: gpg: Signature made Mon 09 Mar 2020 03:52:13 PM UTC using RSA key ID 69475BAA
5:36:29 PM: gpg: Good signature from "Yarn Packaging <[email protected]>"
5:36:29 PM: gpg: WARNING: This key is not certified with a trusted signature!
5:36:29 PM: gpg:          There is no indication that the signature belongs to the owner.
5:36:29 PM: Primary key fingerprint: 72EC F46A 56B4 AD39 C907  BBB7 1646 B01B 86E5 0310
5:36:29 PM:      Subkey fingerprint: 6D98 490C 6F1A CDDD 448E  4595 4F77 6793 6947 5BAA
5:36:29 PM: > GPG signature looks good
5:36:29 PM: > Extracting to ~/.yarn...
5:36:29 PM: > Adding to $PATH...
5:36:30 PM: > Successfully installed Yarn 1.22.4! Please open another terminal where the `yarn` command will now be available.
5:36:30 PM: Installing NPM modules using Yarn version 1.22.4
5:36:30 PM: yarn install v1.22.4
5:36:30 PM: [1/4] Resolving packages...
5:36:31 PM: [2/4] Fetching packages...
5:36:42 PM: info [email protected]: The platform "linux" is incompatible with this module.
5:36:42 PM: info "[email protected]" is an optional dependency and failed compatibility check. Excluding it from installation.
5:36:42 PM: info [email protected]: The platform "linux" is incompatible with this module.
5:36:42 PM: info "[email protected]" is an optional dependency and failed compatibility check. Excluding it from installation.
5:36:42 PM: [3/4] Linking dependencies...
5:36:46 PM: [4/4] Building fresh packages...
5:36:50 PM: Done in 19.73s.
5:36:50 PM: NPM modules installed using Yarn
5:36:50 PM: Started restoring cached go cache
5:36:50 PM: Finished restoring cached go cache
5:36:50 PM: go version go1.14.4 linux/amd64
5:36:50 PM: go version go1.14.4 linux/amd64
5:36:50 PM: Installing missing commands
5:36:50 PM: Verify run directory
5:36:52 PM: ​
5:36:52 PM: ────────────────────────────────────────────────────────────────
5:36:52 PM:   Netlify Build                                                 
5:36:52 PM: ────────────────────────────────────────────────────────────────
5:36:52 PM: ​
5:36:52 PM: ❯ Version
5:36:52 PM:   @netlify/build 7.0.0
5:36:52 PM: ​
5:36:52 PM: ❯ Flags
5:36:52 PM:   deployId: 5fd5fcb20cd506b6ee26c0bc
5:36:52 PM:   mode: buildbot
5:36:52 PM: ​
5:36:52 PM: ❯ Current directory
5:36:52 PM:   /opt/build/repo
5:36:52 PM: ​
5:36:52 PM: ❯ Config file
5:36:52 PM:   No config file was defined: using default values.
5:36:52 PM: ​
5:36:52 PM: ❯ Context
5:36:52 PM:   production
5:36:52 PM: ​
5:36:52 PM: ❯ Installing plugins
5:36:52 PM:    - @netlify/[email protected]
5:37:25 PM: ​
5:37:25 PM: ❯ Loading plugins
5:37:25 PM:    - @netlify/[email protected] from Netlify app
5:37:26 PM: ​
5:37:26 PM: ────────────────────────────────────────────────────────────────
5:37:26 PM:   1. onPreBuild command from @netlify/plugin-nextjs             
5:37:26 PM: ────────────────────────────────────────────────────────────────
5:37:26 PM: ​
5:37:26 PM: ** Adding next.config.js with target set to 'serverless' **
5:37:26 PM: ​
5:37:26 PM: (@netlify/plugin-nextjs onPreBuild completed in 10ms)
5:37:26 PM: ​
5:37:26 PM: ────────────────────────────────────────────────────────────────
5:37:26 PM:   2. Build command from Netlify app                             
5:37:26 PM: ────────────────────────────────────────────────────────────────
5:37:26 PM: ​
5:37:26 PM: $ yarn build
5:37:26 PM: yarn run v1.22.4
5:37:26 PM: $ next build
5:37:27 PM: warn  - No build cache found. Please configure build caching for faster rebuilds. Read more: https://err.sh/next.js/no-cache
5:37:27 PM: info  - Creating an optimized production build...
5:37:51 PM: warn  - Compiled with warnings
5:37:51 PM: ./node_modules/next/dist/next-server/server/load-components.js
5:37:51 PM: Critical dependency: the request of a dependency is an expression
5:37:51 PM: ./node_modules/next/dist/next-server/server/load-components.js
5:37:51 PM: Critical dependency: the request of a dependency is an expression
5:37:51 PM: ./node_modules/next/dist/next-server/server/require.js
5:37:51 PM: Critical dependency: the request of a dependency is an expression
5:37:51 PM: ./node_modules/next/dist/next-server/server/require.js
5:37:51 PM: Critical dependency: the request of a dependency is an expression
5:37:51 PM: ./node_modules/next/dist/next-server/server/require.js
5:37:51 PM: Critical dependency: the request of a dependency is an expression
5:37:51 PM: ./node_modules/next/node_modules/node-fetch/lib/index.js
5:37:51 PM: Module not found: Can't resolve 'encoding' in '/opt/build/repo/node_modules/next/node_modules/node-fetch/lib'
5:37:51 PM: info  - Collecting page data...
5:37:52 PM: info  - Generating static pages (0/4)
5:37:53 PM: info  - Generating static pages (1/4)
5:37:53 PM: info  - Generating static pages (2/4)
5:37:53 PM: info  - Generating static pages (3/4)
5:37:53 PM: info  - Generating static pages (4/4)
5:37:53 PM: info  - Finalizing page optimization...
5:37:53 PM: Page                                Size     First Load JS
5:37:53 PM: ┌ ● / (ISR: 1 Seconds)              1.97 kB        64.3 kB
5:37:53 PM: ├   /_app                           0 B            62.3 kB
5:37:53 PM: ├ ○ /404                            3.01 kB        65.4 kB
5:37:53 PM: ├ λ /api/hello                      0 B            62.3 kB
5:37:53 PM: └ ● /blog/[id]                      1.94 kB        64.3 kB
5:37:53 PM:     ├ /blog/static-site-generation
5:37:53 PM:     └ /blog/test-post
5:37:53 PM: + First Load JS shared by all       62.3 kB
5:37:53 PM:   ├ chunks/commons.40559a.js        12.8 kB
5:37:53 PM:   ├ chunks/framework.ef157c.js      41.8 kB
5:37:53 PM:   ├ chunks/main.c60f4c.js           6.54 kB
5:37:53 PM:   ├ chunks/pages/_app.e774f4.js     526 B
5:37:53 PM:   ├ chunks/webpack.e06743.js        751 B
5:37:53 PM:   └ css/6fcf17ab8077bd559672.css    2.31 kB
5:37:53 PM: λ  (Lambda)  server-side renders at runtime (uses getInitialProps or getServerSideProps)
5:37:53 PM: ○  (Static)  automatically rendered as static HTML (uses no initial props)
5:37:53 PM: ●  (SSG)     automatically generated as static HTML + JSON (uses getStaticProps)
5:37:53 PM:    (ISR)     incremental static regeneration (uses revalidate in getStaticProps)
5:37:53 PM: Done in 26.75s.
5:37:53 PM: ​
5:37:53 PM: (build.command completed in 27s)
5:37:53 PM: ​
5:37:53 PM: ────────────────────────────────────────────────────────────────
5:37:53 PM:   3. onBuild command from @netlify/plugin-nextjs                
5:37:53 PM: ────────────────────────────────────────────────────────────────
5:37:53 PM: ​
5:37:53 PM: ** Running Next on Netlify package **
5:37:53 PM: 🚀 Next on Netlify 🚀
5:37:53 PM:    Functions directory:  netlify-automatic-functions
5:37:53 PM:    Publish directory:  /opt/build/repo
5:37:53 PM:    Make sure these are set in your netlify.toml file.
5:37:53 PM: 🌍️ Copying public/ folder to /opt/build/repo
5:37:53 PM: 💼 Copying static NextJS assets to /opt/build/repo
5:37:53 PM: 💫 Setting up API endpoints as Netlify Functions in netlify-automatic-functions
5:37:53 PM: 💫 Setting up pages with getInitialProps as Netlify Functions in netlify-automatic-functions
5:37:53 PM: 💫 Setting up pages with getServerSideProps as Netlify Functions in netlify-automatic-functions
5:37:53 PM: 🔥 Copying pre-rendered pages with getStaticProps and JSON data to /opt/build/repo
5:37:53 PM: 💫 Setting up pages with getStaticProps and fallback: true as Netlify Functions in netlify-automatic-functions
5:37:53 PM: 💫 Setting up pages with getStaticProps and revalidation interval as Netlify Functions in netlify-automatic-functions
5:37:53 PM: 🔥 Copying pre-rendered pages without props to /opt/build/repo
5:37:53 PM: 🔀 Setting up redirects
5:37:53 PM: ​
5:37:53 PM: (@netlify/plugin-nextjs onBuild completed in 167ms)
5:37:53 PM: ​
5:37:53 PM: ────────────────────────────────────────────────────────────────
5:37:53 PM:   4. Functions bundling                                         
5:37:53 PM: ────────────────────────────────────────────────────────────────
5:37:53 PM: ​
5:37:53 PM: Packaging Functions from netlify-automatic-functions directory:
5:37:53 PM:  - next_api_hello/next_api_hello.js
5:37:53 PM:  - next_blog_id/next_blog_id.js
5:37:53 PM:  - next_index/next_index.js
5:38:05 PM: ​
5:38:05 PM: (Functions bundling completed in 11.9s)
5:38:05 PM: ​
5:38:05 PM: ────────────────────────────────────────────────────────────────
5:38:05 PM:   Netlify Build Complete                                        
5:38:05 PM: ────────────────────────────────────────────────────────────────
5:38:05 PM: ​
5:38:05 PM: (Netlify Build completed in 1m 12.9s)
5:38:05 PM: Caching artifacts
5:38:05 PM: Started saving node modules
5:38:05 PM: Finished saving node modules
5:38:05 PM: Started saving build plugins
5:38:05 PM: Finished saving build plugins
5:38:05 PM: Started saving yarn cache
5:38:05 PM: Finished saving yarn cache
5:38:05 PM: Started saving pip cache
5:38:06 PM: Finished saving pip cache
5:38:06 PM: Started saving emacs cask dependencies
5:38:06 PM: Finished saving emacs cask dependencies
5:38:06 PM: Started saving maven dependencies
5:38:06 PM: Finished saving maven dependencies
5:38:06 PM: Started saving boot dependencies
5:38:06 PM: Finished saving boot dependencies
5:38:06 PM: Started saving rust rustup cache
5:38:06 PM: Finished saving rust rustup cache
5:38:06 PM: Started saving rust cargo bin cache
5:38:06 PM: Finished saving rust cargo bin cache
5:38:06 PM: Started saving go dependencies
5:38:06 PM: Finished saving go dependencies
5:38:08 PM: Build script success
5:38:08 PM: Starting to deploy site from ''
5:38:08 PM: Creating deploy tree 
5:38:09 PM: Creating deploy upload records
5:38:09 PM: 5 new files to upload
5:38:09 PM: 3 new functions to upload
5:38:10 PM: Starting post processing
5:38:12 PM: Post processing - HTML
5:38:12 PM: Post processing - header rules
5:38:12 PM: Post processing - redirect rules
5:38:12 PM: Post processing done
5:38:13 PM: Site is live ✨
5:38:34 PM: Finished processing build request in 2m14.274321422s

Having "next export" in npm script fails build, even if unused.

Error message ** Static HTML export next.js projects do not require this plugin ** was caused by "export": "next export" existing in my package.json file. I removed "npm run export" from my netlify.toml file when converting my site from SSG to adding some SSR pages, but had left that command in package.json (not documented in any posts that I would need to make sure to remove it).

Was very very confusing to figure out. I think the easiest fix is updating the error message to be more specific to what is detected. But maybe there is another thing to detect off of? I'm new to Next so not sure.

File with detection logic

Also off topic, but for a new NextJS dev the docs around next-on-netlify vs this plugin were confusing. Is next-on-netlify legacy? Is this one the only way to also have custom functions?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.