Git Product home page Git Product logo

vercel-builder's Introduction

vercel-builder

Nuxt Vercel Builder

npm version npm downloads packagephobia Github actions status Codecov Dependencies Standard JS

⚠️ This is a legacy builder and only works for Nuxt 2. We'd strongly recommend using Nuxt Bridge or Nuxt 3, which use the latest Vercel features instead.


@nuxtjs/vercel-builder allows you ship a fast, production-ready Nuxt 2 application that scales automatically on Vercel when using SSR rendering.

When to use it

This package is only made for Nuxt 2 SSR applications - and you probably do not need to use it.

👉 If you want to deploy a statically generated Nuxt 2 application instead, Vercel is a zero configuration provider. Check this guide from Vercel for more information.

👉 If you want to deploy a Nuxt Bridge or Nuxt 3 app, Vercel deployment will work with zero configuration. Check this guide for more information.

⚠️ We would advise you migrate your app to Nuxt 3, which features a much superior integration with Vercel using their latest Build API.

How it works

This Vercel builder takes a Nuxt application defined by a nuxt.config.js (or .ts) entrypoint and deploys it as a serverless function in a Vercel environment.

It features built-in caching of node_modules and the global yarn cache (even when dependencies change) and a multi-stage build for fast and small deployments.

Setup

All you need is a Nuxt application and a Vercel account.

Then, simply create a vercel.json file at the root of your project:

{
  "version": 2,
  "builds": [
    {
      "src": "nuxt.config.js",
      "use": "@nuxtjs/vercel-builder"
    }
  ]
}

NOTE: When installing your dependencies, Vercel will use the same package manager that is used in the project. Using yarn is highly recommended due to its autoclean functionality, which can decrease lambda size.

Examples

See Basic example for a more complete deployable example, including an example of how to set up vercel dev support.

See Deploying two Nuxt apps side-by-side for details on deploying two Nuxt apps in one monorepo.

Configuration

serverFiles

  • Type: Array

If you need to include files in the server lambda that are not built by webpack (or within static/), such as a local module or serverMiddleware, you may specify them with this option. Each item can be a glob pattern.

Example

{
  "builds": [
    {
      "src": "nuxt.config.js",
      "use": "@nuxtjs/vercel-builder",
      "config": {
        "serverFiles": ["server-middleware/**"]
      }
    }
  ]
}

internalServer

  • Type: Boolean
  • Default: false

If you have defined serverMiddleware in your nuxt.config, this builder will automatically enable an internal server within the lambda so you can access your own endpoints via http://localhost:3000. (This does not affect how you call your endpoints from client-side.)

If you need to enable or disable the internal server manually (for example, if you are adding server middleware via a module), just set internalServer within the builder options.

generateStaticRoutes

  • Type: Boolean
  • Default: false

To pre-render routes during the build using nuxt generate set this to true. Routes that are not generated will fallback to the server lambda. You will need to specify the routes to be generated in your nuxt.config.

Example

{
  "builds": [
    {
      "src": "nuxt.config.js",
      "use": "@nuxtjs/vercel-builder",
      "config": {
        "generateStaticRoutes": true
      }
    }
  ]
}

tscOptions

  • Type: Object

If you need to pass TypeScript compiler options to override your tsconfig.json, you can pass them here. See the TypeScript documentation for valid options.

Example

{
  "src": "nuxt.config.ts",
  "use": "@nuxtjs/vercel-builder",
  "config": {
    "tscOptions": {
      "sourceMap": false
    }
  }
}

You can also include a tsconfig.vercel.json file alongside your tsconfig.json file. The compilerOptions from those files, along with any tscOptions passed through vercel.json, will be merged and the resulting options used to compile your nuxt.config.ts, local modules and serverMiddleware.

memory

  • Type: Number

Pass this option if you need to customize the default memory limit of the serverless function that renders your pages.

maxDuration

  • Type: Number

Pass this option if you need to customize the max duration of the serverless function that renders your pages.

Environment variables

env

If you are accessing environment variables via env within your Nuxt build, then they will be baked in at build time. This means that if you update the variables in the Vercel dashboard, you will need to trigger a deployment again for the changes to take effect. You must include these variables in build.env in your vercel.json (see below).

runtimeConfig

If you are using Nuxt 2.13+, it is recommended to use the new runtimeConfig options instead.

Exposing variables

There are two environments where you may need to expose environment variables within vercel.json. They are env (for runtime variables) and build.env (for build-time variables, which may not be required for runtimeConfig). See Vercel documentation. For example:

{
  "env": {
    "MY_VARIABLE": true
  },
  "build": {
    "env": {
      "MY_VARIABLE": true
    }
  }
}

Finally, note that if you want to access Vercel's system environment variables, you may want ensure that system environment variables are automatically exposed.

Usage with Typescript

vercel-builder supports TypeScript runtime compilation. It adds in a pre-compilation step as part of building the lambda for files not compiled by Webpack, such as nuxt.config.ts, local modules and serverMiddleware.

References to original TS files in strings outside of modules or serverMiddleware may therefore cause unexpected errors.

Don't forget to update your Nuxt config filename in your vercel.json file.

Technical details

Monorepos

Just enable the "Include source files outside of the Root Directory in the Build Step" option in the Root Directory section within the project settings.

Vercel monorepo config

Private npm modules

To install private npm modules, define NPM_AUTH_TOKEN or NPM_TOKEN as a build environment variable in vercel.json.

Alternatively, you can inline your entire .npmrc file in a NPM_RC environment variable.

Node.js version

The newest available Node.js version is automatically selected. If your packages depend on a particular major release Node.js version, you can specify the version in your package.json - see Vercel documentation.

vercel-build script support

This builder will run a given custom build step if you have added a vercel-build key under scripts in package.json.

Deploying additional serverless functions

You can also deploy additional serverless functions alongside your Nuxt application.

serverMiddleware

Create an api folder at the root of your project, and then create a file in it, for example hello.js:

import express from 'express'
import bodyParser from 'body-parser'

const app = express()
app.use(bodyParser.json())

// It is important that the full path is specified here
app.post('/api/hello', function(req, res) {
  const { info } = req.body
  console.log(info)
  res
    .status(200)
    .json({ info })
    .end()
})

export default app

Setup the Vercel config

In your vercel.json, add your additional endpoints:

{
  "version": 2,
  "routes": [
    {
      "src": "/api/hello",
      "dest": "/api/hello.js"
    }
  ],
  "builds": [
    {
      "src": "api/**/*.js",
      "use": "@vercel/node"
    },
    {
      "src": "nuxt.config.ts",
      "use": "@nuxtjs/vercel-builder",
      "config": {
        "serverFiles": ["api/**"]
      }
    }
  ]
}

Add it to the Nuxt config

If you want to interact with this API whilst developing your Nuxt app, you can add it to your serverMiddleware conditionally.

export default {
  serverMiddleware:
    process.env.NODE_ENV === 'production' ? [] : ['~/api/hello.js'],
}

And that's it! You can now go to http://locahost:3000/api/hello and see the result! In production the endpoint will be handled with Vercel, but locally Nuxt will manage it for you.

License

MIT License

Documentation and builder inspired by Next.js by Vercel

Copyright (c) Nuxt Community

vercel-builder's People

Contributors

atinux avatar danielroe avatar dependabot[bot] avatar dtinth avatar ebouther avatar florian-lefebvre avatar gangsthub avatar gomah avatar idorenyinudoh avatar jake-101 avatar kerneggertim avatar kit-p avatar kukac7 avatar lucleray avatar matthewpull avatar micheldenegri avatar miteyema avatar nles avatar pi0 avatar posva avatar reegodev avatar renovate-bot avatar renovate[bot] avatar siilwyn avatar smaeda-ks avatar styfle avatar tootallnate avatar unr 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

vercel-builder's Issues

Deploys to now fail suddenly.

Originally discussing this issue in spectrum #now -> https://spectrum.chat/zeit/now/nuxt-universal-app-deployment-not-working-anymore~982af2e3-7dd4-4193-bd64-dda884ab6df0

After talking with their team, I was told that it appears to be an issue with now-builder itself.

When comparing my failed deployments, vs. my working deployments from this morning the only difference I can see in my deploys is a single dependancy within nuxt/now-builder.

Working Deploy

@now/[email protected]

Failing Deploy

@now/[email protected]

Did something change recently? I don't see any major release, or updates to the package in the nuxt/now-builder repo.

I guess a quick fix would be pinning the version in the nuxt/now-builder... I'm asking for clarity on what happened in now/node-bridge though.

process.env variables not available in client side code

For some reason environment variables set via now.json are only available to the server side rendering of the deployment. console.log(process.env) delivers an empty object.

Is there anything I need to be aware of for my now.json config?

{
  "name": "Website",
  "version": 2,
  "builds": [
    {
      "src": "nuxt.config.js",
      "use": "@nuxtjs/now-builder",
      "config": {
        "serverFiles": [
          "api/**",
          "config/**"
        ]
      }
    }
  ],
  "routes": [
    { "src": "/_nuxt/.+", "headers": { "cache-control": "s-maxage=31536000" } },
    { "src": "/(.*)", "dest": "/" }
  ],
  "build": {
    "env": {
      "DEV_API": "@dev_api",
      "PROD_API": "@prod_api",
      "KIRBY_EMAIL": "@kirby_email",
      "KIRBY_AUTH": "@kirby_auth",
      "GOOGLE_MAPS_KEY": "@google_maps_key",
      "NODEMAILER_PROVIDER": "@nodemailer_provider",
      "NODEMAILER_EMAIL": "@nodemailer_email",
      "NODEMAILER_AUTH": "@nodemailer_auth",
      "RETURNCALL_EMAIL": "@returncall_email",
      "RETURNCALL_WHITELIST": "@returncall_whitelist"
    }
  },
  "env": {
    "DEV_API": "@dev_api",
    "PROD_API": "@prod_api",
    "KIRBY_EMAIL": "@kirby_email",
    "KIRBY_AUTH": "@kirby_auth",
    "GOOGLE_MAPS_KEY": "@google_maps_key",
    "NODEMAILER_PROVIDER": "@nodemailer_provider",
    "NODEMAILER_EMAIL": "@nodemailer_email",
    "NODEMAILER_AUTH": "@nodemailer_auth",
    "RETURNCALL_EMAIL": "@returncall_email",
    "RETURNCALL_WHITELIST": "@returncall_whitelist",
    "NODE_ENV":"production"
  }
}

Status of now-builder. Production ready?

I'm curious about the status of his builder, is it ready to be used in production? This is unclear to me mainly for two reasons:

  1. It is not on the official list of builders: https://zeit.co/docs/v2/deployments/official-builders/overview/

  2. The official Nuxt deployment guide for Now (https://nuxtjs.org/faq/now-deployment) says:

You cannot deploy a server-side-rendered Nuxt app with Now V2 right now. Please use Now V1 for such apps.

It would be advantageous to clarify this in the readme, I think?

Unable to import module 'now__launcher': Error

I'm getting the error:

Unable to import module 'now__launcher': Error     at Generator.next (<anonymous>)
--
REPORT RequestId: f914ffdb-309d-4fcf-b249-e00bb6eb2efb	
Duration: 0.40 ms  Billed Duration: 100 ms   Memory Size: 3008 MB  Max Memory Used: 87 MB	

after I deployed the project using @nuxt/now-builder.

The project is on nuxt v2.5.1.

I used the now.json from the How to use it section:

{
  "version": 2,
  "builds": [
    {
      "src": "nuxt.config.js",
      "use": "@nuxtjs/now-builder",
      "config": {}
    }
  ],
  "routes": [
    {
      "src": "/_nuxt/.+",
      "headers": {
        "cache-control": "s-maxage=31536000"
      }
    },
    {
      "src": "/(.*)",
      "dest": "/"
    }
  ]
}

Is there a way to better debug the error or can I provide more information?

why is yarn highly recommended?

Hi

I have read in the Technical Details of the documentation, that the use of yarn is highly recommended.

Why is that?
Is this specific to the now build platform?
Or is this more in general regarding to nuxt?

TypeError: Path must be a string. Received undefined

Just before the build is successfully finished, just got this error:

TypeError: Path must be a string. Received undefined
--
Aug 30 2019 17:57:59:258 | ...nuxt.config.js | at assertPath (path.js:28:11)
Aug 30 2019 17:57:59:258 | ...nuxt.config.js | at Object.join (path.js:1236:7)
Aug 30 2019 17:57:59:258 | ...nuxt.config.js | at Object.prepareCache (/tmp/8bc17a01883798f1/.build-utils/.builder/node_modules/@nuxtjs/now-builder/lib/prepare-cache.js:9:25)
Aug 30 2019 17:57:59:258 | ...nuxt.config.js | at uploadCacheStep (/var/task/sandbox-worker.js:26330:55)
Aug 30 2019 17:57:59:258 | ...nuxt.config.js | at mainSub (/var/task/sandbox-worker.js:25904:15)
Aug 30 2019 17:57:59:258 | ...nuxt.config.js | at <anonymous>

Error: Cannot find module 'glob-all'

Currrently trying to implement PurgeCSS and running into problems while deploying:

Unable to import module 'now__launcher': Error
Error: Cannot find module 'glob-all'
Require stack:
- /var/task/nuxt.config.js
- /var/task/now__launcher.js
- /var/runtime/node_modules/awslambda/index.js
    at Object.<anonymous> (/var/task/nuxt.config.js:2:14)
    at Generator.next (<anonymous>)

nuxt.config.js

const join = require('path').join
const glob = require('glob-all')
const PurgecssPlugin = require('purgecss-webpack-plugin')
const tailwindJS = join(__dirname, 'tailwind.js')
// const pkg = require('./package')
const { I18N } = require('./config')
require('dotenv').config()

class TailwindExtractor {
  static extract(content) {
    return content.match(/[A-z0-9-:/]+/g) || []
  }
}

module.exports = {
  mode: 'universal',
  head: {
    // title: pkg.name,
    meta: [
      { charset: 'utf-8' },
      { name: 'viewport', content: 'width=device-width, initial-scale=1' },
      { hid: 'description', name: 'description', content: '' },
      { name: 'theme-color', content: '#ffffff' }
    ],
    link: [{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }]
  },
  loading: false,
  css: ['assets/css/tailwind.css', 'assets/css/global.postcss'],
  plugins: [
    { src: '~/plugins/axios.js', ssr: true },
    { src: '~/plugins/axios-methods.js', ssr: true },
    { src: '~/plugins/i18n.js', ssr: true },
    { src: '~/plugins/parser.js', ssr: true },
    { src: '~/plugins/global-components.js', ssr: true },
    { src: '~plugins/vuex-router-sync.js', ssr: true },
    { src: '~plugins/find-page.js', ssr: true },
    { src: '~plugins/googlemaps.js', ssr: false },
    { src: '~/plugins/polyfills.js', ssr: false }
  ],
  env: {
    kirbyEmail: process.env.KIRBY_EMAIL,
    kirbyAuth: process.env.KIRBY_AUTH,
    googlemapsKey: process.env.GOOGLEMAPS_KEY,
    baseURL:
      process.env.NODE_ENV !== 'production'
        ? process.env.DEV_API
        : process.env.PROD_API
  },
  serverMiddleware: ['~/api/index.js'],
  modules: [
    '@nuxtjs/axios',
    '@nuxtjs/pwa',
    '@nuxtjs/dotenv',
    ['nuxt-i18n', I18N]
  ],
  router: {
    middleware: 'fetch'
  },
  build: {
    extractCSS: true,
    postcss: {
      plugins: {
        precss: {},
        tailwindcss: tailwindJS
      },
      preset: {
        stage: 0,
        preserve: false
      }
    },
    extend(config, ctx) {
      // Enable i18n blocks
      config.module.rules.push({
        resourceQuery: /blockType=i18n/,
        type: 'javascript/auto',
        loader: ['@kazupon/vue-i18n-loader']
      })
      // Run ESLint on save
      if (ctx.isDev && ctx.isClient) {
        config.module.rules.push({
          enforce: 'pre',
          test: /\.(js|vue)$/,
          loader: 'eslint-loader',
          exclude: /(node_modules)/
        })
      }
      if (!ctx.isDev && ctx.isClient) {
        config.plugins.push(
          new PurgecssPlugin({
            // purgecss configuration
            // https://github.com/FullHuman/purgecss
            paths: glob.sync([
              join(__dirname, './pages/**/*.vue'),
              join(__dirname, './layouts/**/*.vue'),
              join(__dirname, './components/**/*.vue'),
              join(__dirname, './assets/css/*.postcss')
            ]),
            extractors: [
              {
                extractor: TailwindExtractor,
                extensions: ['vue']
              }
            ],
            whitelist: ['html', 'body']
          })
        )
      }
    }
  }
}

Would be greatful for a workaround!

Error: The results of prepareCache must be produced by glob against workPath

I'm trying to setup Now deployment for our Nuxt project (which builds/starts/runs dev fine) and hitting this error on Now:

----------------- Collect cache -----------------
--
12:58:15 AM | ℹ 0 files collected from .now_cache
12:58:20 AM | ℹ 30855 files collected from node_modules_dev
12:58:22 AM | ℹ 10100 files collected from node_modules_prod
12:58:22 AM | ℹ Collect cache took: 6785.539765 ms
12:58:22 AM | Build completed. Populating build cache...
12:58:22 AM | Error: The results of prepareCache must be produced by glob against workPath or prepareCachePath
12:58:22 AM | at packCache (/var/task/sandbox-worker.js:26382:15)
12:58:22 AM | at uploadCacheStep (/var/task/sandbox-worker.js:26347:28)
12:58:22 AM | at <anonymous>
12:58:22 AM | done

This seems loosely related to #111 but a different error message. This is what our now.json looks like:

{
  "version": 2,
  "builds": [{
    "src": "nuxt/indieshops/nuxt.config.js",
    "use": "@nuxtjs/now-builder",
    "config": {}
  }]
}

Serving the application fails - Error: Cannot find module '@nuxtjs/eslint-module'

Hi there,

trying to use this builder for my nuxt application but I’m getting an error when serving the app.

  • works fine with now/static-build
  • using nuxt 2.8.1
  • now.json below
  • nuxt.config below
  • output logs from ZEIT now below
  • package.json below
  • Deployment URL: https://www-efu6bvof8.now.sh/

now.json

{
  "version": 2,
  "builds": [
    {
      "src": "nuxt.config.js",
      "use": "@nuxtjs/now-builder",
      "config": {}
    }
  ],
  "routes": [
    { "src": "/_nuxt/.+", "headers": { "Cache-Control": "max-age=31557600" } },
    { "src": "/(.*)", "dest": "/" }
  ]
}

Package.json

{
  "name": "tresor",
  "version": "1.0.0",
  "description": "Komm klar mit deinen Finanzen",
  "author": "Sumit Kumar",
  "private": true,
  "scripts": {
    "lint": "eslint --ext .js,.vue --ignore-path .gitignore .",
    "precommit": "yarn run lint",
    "dev": "cross-env NODE_ENV=development nodemon server/index.js --watch server",
    "build": "nuxt build",
    "now-build": "nuxt build",
    "start": "cross-env NODE_ENV=production node server/index.js",
    "generate": "nuxt generate"
  },
  "dependencies": {
    "@nuxtjs/axios": "^5.3.6",
    "@nuxtjs/bulma": "^1.2.1",
    "cross-env": "^5.2.0",
    "express": "^4.16.4",
    "node-sass": "^4.12.0",
    "nuxt": "^2.8.1",
    "sass-loader": "^7.1.0",
    "vue-focus": "^2.1.0"
  },
  "devDependencies": {
    "@nuxtjs/eslint-config": "^0.0.1",
    "@nuxtjs/eslint-module": "^0.0.1",
    "babel-eslint": "^10.0.1",
    "eslint": "^5.15.1",
    "eslint-config-prettier": "^4.1.0",
    "eslint-config-standard": ">=12.0.0",
    "eslint-plugin-import": ">=2.16.0",
    "eslint-plugin-jest": ">=22.3.0",
    "eslint-plugin-node": ">=8.0.1",
    "eslint-plugin-nuxt": ">=0.4.2",
    "eslint-plugin-prettier": "^3.0.1",
    "eslint-plugin-promise": ">=4.0.1",
    "eslint-plugin-standard": ">=4.0.0",
    "eslint-plugin-vue": "^5.2.2",
    "nodemon": "^1.18.9",
    "prettier": "^1.16.4"
  }
}

nuxt.config

module.exports = {
  mode: 'universal',
  /*
   ** Headers of the page
   */
  head: {
    title: 'Tresor - Komm klar mit deinen Finanzen',
    meta: [
      { charset: 'utf-8' },
      { name: 'viewport', content: 'width=device-width, initial-scale=1' },
      {
        hid: 'description',
        name: 'description',
        content: process.env.npm_package_description || ''
      }
    ],
    link: [{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }]
  },
  /*
   ** Customize the progress-bar color
   */
  loading: { color: '#fff' },
  /*
   ** Global CSS
   */
  css: [],
  /*
   ** Plugins to load before mounting the App
   */
  plugins: [],
  /*
   ** Nuxt.js modules
   */
  modules: [
    // Doc:https://github.com/nuxt-community/modules/tree/master/packages/bulma
    '@nuxtjs/bulma',
    // Doc: https://axios.nuxtjs.org/usage
    '@nuxtjs/axios',
    '@nuxtjs/eslint-module'
  ],
  /*
   ** Axios module configuration
   ** See https://axios.nuxtjs.org/options
   */
  axios: {},
  /*
   ** Build configuration
   */
  build: {
    postcss: {
      preset: {
        features: {
          customProperties: false
        }
      }
    },
    /*
     ** You can extend webpack config here
     */
    extend(config, ctx) {}
  }
}

Output:

TART RequestId: 7be2acd5-5cf6-44c9-bc89-df5887d1fc3b Version: $LATEST
2019-06-22T11:29:13.419Z	20411dd3-9f6c-48a9-b4c2-b86874142c7a	λ Error while initializing nuxt: { /var/task/node_modules/@nuxt/core/dist/core.js:1
Error: Cannot find module '@nuxtjs/eslint-module'
Require stack:
- /var/task/node_modules/@nuxt/core/dist/core.js
- /var/task/now__launcher.js
- /var/runtime/node_modules/awslambda/index.js
    at Resolver.requireModule (/var/task/node_modules/@nuxt/core/dist/core.js:627:31)
    at ModuleContainer.addModule (/var/task/node_modules/@nuxt/core/dist/core.js:163:36)
    at promise.then (/var/task/node_modules/@nuxt/utils/dist/utils.js:1796:43)
    at <anonymous>
    at process._tickDomainCallback (internal/process/next_tick.js:228:7)
  code: 'MODULE_NOT_FOUND',
  requireStack: 
   [ '/var/task/node_modules/@nuxt/core/dist/core.js',
     '/var/task/now__launcher.js',
     '/var/runtime/node_modules/awslambda/index.js' ] }
END RequestId: 7be2acd5-5cf6-44c9-bc89-df5887d1fc3b
REPORT RequestId: 7be2acd5-5cf6-44c9-bc89-df5887d1fc3b	
Duration: 62.48 ms  Billed Duration: 100 ms   Memory Size: 3008 MB  Max Memory Used: 47 MB	
RequestId: 7be2acd5-5cf6-44c9-bc89-df5887d1fc3b Process exited before completing request


Spotted error in output logs:

Error: Cannot find module '@nuxtjs/eslint-module'

Any idea what I might be doing wrong here?

Nuxt.js Internal Server Error with firebase

Hello

Everything is fine when I work in locally but in production I get Nuxt.js Internal Server Error.

I found some threads about this issue with Next.js and it seems if you only import submodules of firebase in Next.js, it works fine.

Firebase + Next.JS

How to get a next.js / firestore project to deploy on Zeit 2.0?

Actually, I only import submodules but still doesn't work properly.

This is my commit added firebase into project

This project uses nuxt v2.6.3 and firebase v6.0.1.

Anyone has an idea to solve this issue?

Static folders are included in lambda artifacts

I've seen that /static directiory in considered in labmda artifacts. We've vidoes which are there for static pages and ideally it should not be there in artifacts. It should be served directly with some static serve method of zeit.

As artifacts size is limited to 50mb. I am unable to deploy it to the zeit.

Env Variables in nuxt.config.js

I am accessing some environment variables in my nuxt config for nuxt-auth oauth setup. It at least seems like the environment variables from now aren't available in the config file.

I set them up properly with now.sh and am able to log them from a page file but when I make the oauth call it doesn't appear to be sending along the app id in the url params. I can provide more information on my setup if you need but I'm really just curious about what happens to the next config file with the now builder.

Also I made sure to set up a new oauth app for my now.sh domain. It works fine using local nuxt and my oauth app set to localhost.

nuxt.config.js

auth: {
    redirect: {
      callback: '/callback'
    },
    strategies: {
      github: {
        client_id: process.env.GITHUB_CLIENT_ID,
        client_secret: process.env.GITHUB_CLIENT_SECRET
      }
    }
  }

Unable to specify unique nuxt.config.js filenames.

Maybe I just haven't gotten it working properly, but I can't seem to get this working.

I have two nuxt apps, that share modules. I'm planning on using the @nuxt/now-builder to serve these on now.sh

I am trying to run a build with a unique name, instead of using nuxt.config.js I'm trying to use app.config.js and admin.config.js

Each time I try to set this up, I'm given the error:

----------------- Prepare build ----------------- 
Entry directory: .
Error: Entrypoint should point to the nuxt.config
    at Object.build (/tmp/utils/build-module/node_modules/@nuxtjs/now-builder/lib/build.js:24:11)
    at continueBuilding (/var/task/worker.js:16359:42)
    at <anonymous>

It looks like builder.js is verifying that you've pointed to nuxt.config.js explicitly? https://github.com/nuxt/now-builder/blob/master/lib/build.js#L23

Is there any specific reason this is strict to nuxt.config.js and not just looking at the builder.src I'm passing in?

I'm hoping to have a now.json like so:

{
	"builds": [
		{ "src": "app.config.js", "use": "@nuxtjs/now-builder" }
		{ "src": "admin.config.js", "use": "@nuxtjs/now-builder" }
	],
}

Unable to import module 'now__launcher': Error

After taking my nuxt project which was deployed on now 2 in SPA mode and following the README the deployment builds without error but when trying to access the site I get the following error in the logs:

02/24 12:39 PM (7m)
(output/index)
Unable to import module 'now__launcher': Error
- /var/task/now__launcher.js
- /var/runtime/node_modules/awslambda/index.js
    at Object.<anonymous> (/var/task/nuxt.config.js:1)
    at Generator.next (<anonymous>)
02/24 12:39 PM (7m)
(output/index)
REPORT RequestId: e740062e-446b-4f11-9941-cb86786f6089	Duration: 0.52 ms	Billed Duration: 100 ms 	Memory Size: 3008 MB	Max Memory Used: 83 MB	

Cannot GET / after successful deploy

Hello, I noticed a fact that can be quite disturbing depending on the project.

After a new deployment, depending on the size of the project, it is possible that when we access the url, we receive as a message Cannot Get /

After looking at the logs, there is no error or bug in the Lambda which is normal because we can not consider this an error. It's just that the way the builder is done, the request to the url can happen and be resolved before Nuxt is ready.

Example, for my part I received this as log after a fresh deployment:

2019-03-23T13:40:39.751Z  REPORT RequestId: 0446eb3a-8b30-45c1-a6a8-1aa2d6234f03        Duration: 81.91 ms      Billed Duration: 100 ms         Memory Size: 3008 MB    Max Memory Used: 104 MB
2019-03-23T13:40:39.892Z  REPORT RequestId: 5cef5112-3874-4259-a9d6-1df6541a5166        Duration: 3.91 ms       Billed Duration: 100 ms         Memory Size: 3008 MB    Max Memory Used: 104 MB
2019-03-23T13:40:52.361Z  REPORT RequestId: 6c17a74a-6436-42ae-9ec6-039f9c2c6d08        Duration: 4.47 ms       Billed Duration: 100 ms         Memory Size: 3008 MB    Max Memory Used: 107 MB
2019-03-23T13:41:34.519Z  REPORT RequestId: 0599c7c4-75ca-4520-b4d1-47b683af8102        Duration: 14.47 ms      Billed Duration: 100 ms         Memory Size: 3008 MB    Max Memory Used: 107 MB
2019-03-23T13:41:37.086Z  λ Cold start took: 57685.718293ms

I made a first request followed by 3 tab refresh. It was only after 57s that Nuxt was finally ready. The following request showed me the good result.

So I was wondering if it was possible to reduce the cold start or put a loading screen and if there was a difference between nuxt.server.app(req, res) and nuxt.render(req, res)?

Does not work with fresh nuxt installation

What

Does not build with fresh nuxt installation

Steps to reproduce

  1. npx create-nuxt-app testing
  2. cd testing
  3. Add now.json:
{
    "version": 2,
    "builds": [
      {
        "src": "nuxt.config.js",
        "use": "@nuxtjs/now-builder",
        "config": {}
      }
    ],
    "routes": [
      { "src": "/_nuxt/.+", "headers": { "cache-control": "s-maxage=31536000" } },
      { "src": "/(.*)", "dest": "/" }
    ]
  }
  1. now
  2. Receive build error:
Error: Unable to update lock within the stale threshold
    at options.fs.stat (/tmp/490b4653/node_modules_dev/proper-lockfile/lib/lockfile.js:121:25)
    at /tmp/490b4653/node_modules_dev/graceful-fs/polyfills.js:285:20
    at FSReqWrap.oncomplete (fs.js:153:5)
{ Error: Command failed: nuxt build --standalone --config-file "nuxt.config.js"
null
null
    at makeError (/tmp/utils/build-module/node_modules/execa/index.js:174:9)
    at Promise.all.then.arr (/tmp/utils/build-module/node_modules/execa/index.js:278:16)
    at <anonymous>
    at process._tickDomainCallback (internal/process/next_tick.js:228:7)
  code: 1,
  stdout: null,
  stderr: null,
  failed: true,
  signal: null,
  cmd: 'nuxt build --standalone --config-file "nuxt.config.js"',
  timedOut: false,
  killed: false }

Sample

Sample project available at https://github.com/mikkokut/nuxt-now-test

Unable to update lock within the stale threshold

I can not build my project on now anymore.
Locally, the production build works well.

nuxt version: 2.5.1

now.json

{
  "version": 2,
  "regions": ["all"],
  "builds": [
    {
      "src": "nuxt.config.js",
      "use": "@nuxtjs/now-builder",
      "config": {}
    }
  ],
  "routes": [
    { "src": "/_nuxt/.+", "headers": { "cache-control": "s-maxage=31536000" } },
    { "src": "/(.*)", "dest": "/" }
  ]
}

I receive this build error:

2019-03-22T19:54:40.572Z  19:54:40  ----------------- Nuxt build -----------------
2019-03-22T19:54:40.573Z  19:54:40 Running nuxt build --standalone --config-file "nuxt.config.js"
2019-03-22T19:54:42.556Z  19:54:42 ℹ Production build
2019-03-22T19:54:42.562Z  19:54:42 ✔ Builder initialized
2019-03-22T19:54:42.619Z  19:54:42 ✔ Nuxt files generated
2019-03-22T19:54:42.845Z  webpackbar 19:54:42 ℹ Compiling Client
2019-03-22T19:55:07.526Z  webpackbar 19:55:07 ✔ Client: Compiled successfully in 24.68s
2019-03-22T19:55:07.537Z  webpackbar 19:55:07 ℹ Compiling Server
2019-03-22T19:55:33.515Z  19:55:33  WARN  Unable to update lock within the stale threshold

                            at options.fs.stat (node_modules_dev/proper-lockfile/lib/lockfile.js:121:25)
                            at node_modules_dev/graceful-fs/polyfills.js:285:20
                            at FSReqWrap.oncomplete (fs.js:153:5)

2019-03-22T19:55:33.533Z  webpackbar 19:55:33 ✔ Server: Compiled successfully in 26.00s

2019-03-22T19:55:33.538Z  19:55:33  FATAL  Lock is already released
                          
                            at callback (node_modules_dev/proper-lockfile/lib/lockfile.js:241:60)
                            at Promise (node_modules_dev/proper-lockfile/lib/adapter.js:39:9)
                            at new Promise (<anonymous>)
                            at args (node_modules_dev/proper-lockfile/lib/adapter.js:30:25)
                            at NuxtCommand.lockRelease [as _lockRelease] (node_modules_dev/@nuxt/utils/dist/utils.js:139:11)
                            at NuxtCommand.releaseLock (node_modules_dev/@nuxt/cli/dist/cli-chunk.js:244:18)
                            at NuxtCommand.run (node_modules_dev/@nuxt/cli/dist/cli-chunk.js:159:18)
                            at <anonymous>
                            at process._tickDomainCallback (internal/process/next_tick.js:228:7)
                          
2019-03-22T19:55:33.585Z     ╭─────────────────────────────────────╮
                             │                                     │
                             │   ✖ Nuxt Fatal Error                │
                             │                                     │
                             │   Error: Lock is already released   │
                             │                                     │
                             ╰─────────────────────────────────────╯
                          
2019-03-22T19:55:33.622Z  { Error: Command failed: nuxt build --standalone --config-file "nuxt.config.js"
                          null
                          null
                              at makeError (/tmp/utils/build-module/node_modules/execa/index.js:174:9)
                              at Promise.all.then.arr (/tmp/utils/build-module/node_modules/execa/index.js:278:16)
                              at <anonymous>
                              at process._tickDomainCallback (internal/process/next_tick.js:228:7)
                            code: 1,
                            stdout: null,
                            stderr: null,
                            failed: true,
                            signal: null,
                            cmd: 'nuxt build --standalone --config-file "nuxt.config.js"',
                            timedOut: false,
                            killed: false }

Problems with TypeScript

Trying out this builder for a Nuxt + TypeScript project.

Got bunch of these kind of TS errors during build:
Screenshot 2019-04-06 at 11 41 29

Apparently caused by how the now build step will have the node_modules symlinked to node_modules_dev, and how ts-node handles symlinks (TypeStrong/ts-node#396).

One quick solution is to add NODE_PRESERVE_SYMLINKS environment value to the execution of nuxt build (like this: nles@fce3630).

Also, in your tsconfig.json file you'll need to have:

  "exclude": [
    "node_modules",
    "node_modules_dev",
    "node_modules_prod"
  ]

Probably not the best solution to the problem, but leaving this here if someone else is having issues with TypeScript support and needs a solution.

Action Required: Fix Renovate Configuration

There is an error with this repository's Renovate configuration that needs to be fixed. As a precaution, Renovate will stop PRs until it is resolved.

Error type: undefined. Note: this is a nested preset so please contact the preset author if you are unable to fix it yourself.

Nuxt 2.9.1 requires an incompatible version of execa

A clean install of Nuxt from create-nuxt-app fails to deploy to now with the following error:

error [email protected]: The engine "node" is incompatible with this module. Expected version "^8.12.0 \|\| >=9.7.0". Got "8.10.0"

The issue is produced by @nuxt/cli 2.9.1 requiring execa 2.0.4 (previously it required 1.0.0).

A work-around for the moment is adding the following to package.json:

  "resolutions": {
    "execa": "<=2.0.0"
  }

Also note comments to #74.

Expose additional logging for errors

I was able to set up the builder using the documentation, which build Nuxt and deploys to Now without any errors. However, when hitting the deployed URL I see the following:

Nuxt.js Internal Server Error

There are no warnings or errors during the build, and the actual logs that are output for the request are not giving any indication as to what is causing the "Internal Server Error". These are the only things output in the request logs:

OUTPUT	Jun 18 2019 12:49:37:400	/index
START RequestId: d8db75c4-60fa-4d19-94b6-42663381b7a8 Version: $LATEST
END RequestId: d8db75c4-60fa-4d19-94b6-42663381b7a8
REPORT RequestId: d8db75c4-60fa-4d19-94b6-42663381b7a8	
Duration: 69.14 ms  Billed Duration: 100 ms   Memory Size: 3008 MB  Max Memory Used: 213 MB	
OUTPUT	Jun 18 2019 12:49:41:092	/index
START RequestId: ca3ec6a6-f830-4edd-a100-c5f3144ae327 Version: $LATEST
END RequestId: ca3ec6a6-f830-4edd-a100-c5f3144ae327
REPORT RequestId: ca3ec6a6-f830-4edd-a100-c5f3144ae327	
Duration: 5.44 ms  Billed Duration: 100 ms   Memory Size: 3008 MB  Max Memory Used: 213 MB	
OUTPUT	Jun 18 2019 12:49:41:093	/index
START RequestId: e9deb4ff-2ab1-4dce-8cc3-6f52b439297b Version: $LATEST
2019-06-18T17:49:43.609Z	e9deb4ff-2ab1-4dce-8cc3-6f52b439297b	λ Cold start took: 2067.685524ms
END RequestId: e9deb4ff-2ab1-4dce-8cc3-6f52b439297b
REPORT RequestId: e9deb4ff-2ab1-4dce-8cc3-6f52b439297b	

Would be great to expose additional logging in the request logs to trace this issue, especially when dealing with a deployed environment which will behaves differently from local.

publicPath in nuxt.config.js build causes 404 errors for .js files

I have publicPath like following in my nuxt.config:

build: {
  publicPath: '/se/_nuxt/',
  //...
}

which causes 404 errors for the .js files on now v2. It works great in other node environments like now v1 or others I have.

Is there a way to achieve that with now v2?

Builds are failing using 0.16.5

Builds were working just fine using now-builder on 0.16.4. With no code changes (just rebuilding the same commit) builds stopped working when 0.16.5 was released. We didn't have the now-builder version manually specified in our now.json file previously so we automatically got the update. It appears almost as if the devDependencies were no longer installed when attempting the build. Here is a successfull build using 0.16.4:

04:28:57 PM | Installing build runtime...
-- | --
04:29:01 PM | Build runtime installed: 3058.655ms
04:29:01 PM | Looking up build cache...
04:29:19 PM | Build cache unpacked: 17538.188ms
04:29:19 PM | ----------------- Prepare build -----------------
04:29:19 PM | Downloading files...
04:29:20 PM | Working directory: /tmp/71dec833
04:29:20 PM | Using npm
04:29:20 PM | ℹ Prepare build took: 1321.554319 ms
04:29:20 PM | ----------------- Install devDependencies -----------------
04:29:20 PM | Running npm install
04:29:29 PM | npm WARN
04:29:29 PM | optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/@nuxt/builder/node_modules/fsevents):
04:29:29 PM | npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
04:29:29 PM | npm
04:29:29 PM | WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/fsevents):
04:29:29 PM | npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
04:29:29 PM | up to date in 8.135s
04:29:29 PM | ℹ Install devDependencies took: 8486.433934 ms
04:29:29 PM | ----------------- Nuxt build -----------------
04:29:29 PM | Running nuxt build --standalone --no-lock --config-file "nuxt.config.js"
04:29:30 PM | ℹ Production build
04:29:30 PM | ✔ Builder initialized
04:29:30 PM | ✔ Nuxt files generated
04:29:32 PM | ℹ Compiling Client
04:29:51 PM | ✔ Client: Compiled successfully in 18.18s
04:29:51 PM | ℹ Compiling Server
04:30:05 PM | ✔ Server: Compiled successfully in 13.92s
....

And once 0.16.5 was released it started complaining about all the devDependencies (and sub dependencies) not being found:

Installing build runtime...
--
10:37:45 AM | Build runtime installed: 3268.847ms
10:37:46 AM | Looking up build cache...
10:37:46 AM | ----------------- Prepare build -----------------
10:37:46 AM | Downloading files...
10:37:48 AM | Working directory: /fargate/6cefbb23
10:37:48 AM | Using npm
10:37:48 AM | ℹ Prepare build took: 1277.202751 ms
10:37:48 AM | ----------------- Install devDependencies -----------------
10:37:48 AM | Running npm install
10:37:54 AM | npm WARN
10:37:54 AM | notice [SECURITY] set-value has the following vulnerability: 1 high. Go here for more details: https://www.npmjs.com/advisories?search=set-value&version=2.0.0 - Run `npm i npm@latest -g` to upgrade your npm version, and then `npm audit` to get more info.
10:38:01 AM | > [email protected] install /fargate/6cefbb23/node_modules/node-sass
10:38:01 AM | > node scripts/install.js
10:38:01 AM | Downloading binary from https://github.com/sass/node-sass/releases/download/v4.12.0/linux-x64-57_binding.node
10:38:02 AM | Download complete
10:38:02 AM | Binary saved to /fargate/6cefbb23/node_modules_dev/node-sass/vendor/linux-x64-57/binding.node
10:38:02 AM | Caching binary to /fargate/.npm/node-sass/4.12.0/linux-x64-57_binding.node
10:38:03 AM | > [email protected] postinstall /fargate/6cefbb23/node_modules/core-js
10:38:03 AM | > node scripts/postinstall \|\| echo "ignore"
10:38:03 AM | Thank you for using core-js ( https://github.com/zloirock/core-js ) for polyfilling JavaScript standard library!
10:38:03 AM | The project needs your help! Please consider supporting of core-js on Open Collective or Patreon:
10:38:03 AM | > https://opencollective.com/core-js
10:38:03 AM | > https://www.patreon.com/zloirock
10:38:03 AM | Also, the author of core-js ( https://github.com/zloirock ) is looking for a good job -)
10:38:03 AM | > [email protected] postinstall /fargate/6cefbb23/node_modules/node-sass
10:38:03 AM | > node scripts/build.js
10:38:03 AM | Binary found at /fargate/6cefbb23/node_modules_dev/node-sass/vendor/linux-x64-57/binding.node
10:38:03 AM | Testing binary
10:38:03 AM | Binary is fine
10:38:03 AM | > [email protected] postinstall /fargate/6cefbb23/node_modules/nuxt
10:38:03 AM | > opencollective \|\| exit 0
10:38:04 AM | npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/@nuxt/builder/node_modules/fsevents):
10:38:04 AM | npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
10:38:04 AM | npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/fsevents):
10:38:04 AM | npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
10:38:04 AM | added 1330 packages in 16.249s
10:38:04 AM | ℹ Install devDependencies took: 16589.783135 ms
10:38:04 AM | ----------------- Nuxt build -----------------
10:38:04 AM | Running nuxt build --standalone --no-lock --config-file "nuxt.config.js"
10:38:06 AM | ℹ Production build
10:38:06 AM | ✔ Builder initialized
10:38:06 AM | ✔ Nuxt files generated
10:38:09 AM | ℹ Compiling Client
10:38:09 AM | ✔ Client: Compiled with some errors in 719.89ms
10:38:09 AM | Hash: 03cc878000b873ee2fa7
10:38:09 AM | Version: webpack 4.41.0
10:38:09 AM | Time: 722ms
10:38:09 AM | Built at: 2019-10-14 14:38:09
10:38:09 AM | Asset      Size  Chunks               Chunk Names
10:38:09 AM | a929a24db8582babf769.js  1.49 KiB       1  [immutable]  runtime
10:38:09 AM | f3d381992d6e91c2b105.js  1.37 KiB       0  [immutable]  app
10:38:09 AM | Entrypoint app = a929a24db8582babf769.js f3d381992d6e91c2b105.js
10:38:09 AM | ERROR in ./.nuxt/client.js
10:38:09 AM | Module build failed (from ./node_modules_dev/babel-loader/lib/index.js):
10:38:09 AM | Error: Cannot find module '@babel/core'
10:38:09 AM | babel-loader@8 requires Babel 7.x (the package '@babel/core'). If you'd like to use Babel 6.x ('babel-core'), you should install 'babel-loader@7'.
10:38:09 AM | at Function.Module._resolveFilename (module.js:547:15)
10:38:09 AM | at Function.Module._load (module.js:474:25)
10:38:09 AM | at Module.require (module.js:596:17)
10:38:09 AM | at require (internal/module.js:11:18)
10:38:09 AM | at Object.<anonymous> (/fargate/6cefbb23/node_modules_dev/babel-loader/lib/index.js:10:11)
10:38:09 AM | at Module._compile (module.js:652:30)
10:38:09 AM | at Object.Module._extensions..js (module.js:663:10)
10:38:09 AM | at Module.load (module.js:565:32)
10:38:09 AM | at tryModuleLoad (module.js:505:12)
10:38:09 AM | at Function.Module._load (module.js:497:3)
10:38:09 AM | at Module.require (module.js:596:17)
10:38:09 AM | at require (internal/module.js:11:18)
10:38:09 AM | at loadLoader (/fargate/6cefbb23/node_modules_dev/loader-runner/lib/loadLoader.js:18:17)
10:38:09 AM | at iteratePitchingLoaders (/fargate/6cefbb23/node_modules_dev/loader-runner/lib/LoaderRunner.js:169:2)
10:38:09 AM | at runLoaders (/fargate/6cefbb23/node_modules_dev/loader-runner/lib/LoaderRunner.js:365:2)
10:38:09 AM | at NormalModule.doBuild (/fargate/6cefbb23/node_modules_dev/webpack/lib/NormalModule.js:295:3)
10:38:09 AM | @ multi ./.nuxt/client.js app[0]
10:38:09 AM | FATAL  Nuxt build error
....

To temporarily fix this we just manually specified 0.16.4 in our now.json file and all was well again.

{
  "builds": [
    {
      "src": "nuxt.config.js",
      "use": "@nuxtjs/[email protected]",
      "config": {}
    }
  ]
}

Error: Cannot find module 'webpack'

Hello,

after the lastest release of nuxt/now-builder, my project can't compile. I have imported "webpack" (on the first line) in nuxt.config.js.

Complete error from Now:
{ /tmp/7927cdbf/nuxt.config.js:1
Error: Cannot find module 'webpack'
Require stack:

  • /tmp/7927cdbf/nuxt.config.js
  • /tmp/utils/build-module/node_modules/@nuxtjs/now-builder/lib/build.js
  • /tmp/utils/build-module/node_modules/@nuxtjs/now-builder/lib/index.js
  • /var/task/worker.js
    at Object. (/tmp/7927cdbf/nuxt.config.js:1)
    code: 'MODULE_NOT_FOUND',
    requireStack:
    [ '/tmp/7927cdbf/nuxt.config.js',
    '/tmp/utils/build-module/node_modules/@nuxtjs/now-builder/lib/build.js',
    '/tmp/utils/build-module/node_modules/@nuxtjs/now-builder/lib/index.js',
    '/var/task/worker.js' ] }

My nuxtjs version is 2.5.1.
Webpack version 4.29.6.

Cache preparation, non-fatal error from Now

There is a (new) build-time error I've just been seeing today. It is non-fatal, and deployments still work with no problems. The error message is:

TypeError: Path must be a string. Received undefined
    at assertPath (path.js:28:11)
    at Object.join (path.js:1236:7)
    at Object.prepareCache (/tmp/{project-directory}/.build-utils/.builder/node_modules/@nuxtjs/now-builder/lib/prepare-cache.js:9:25)
    at uploadCacheStep (/var/task/sandbox-worker.js:26330:55)
    at <anonymous>
    at process._tickDomainCallback (internal/process/next_tick.js:228:7)
done

Could this be the result of an upstream API change? However, others have experienced it previously. Is anyone else seeing this in their logs?

Edit: Posted in Now chat.

Error: nuxt >= 2.4.0 is required!

Getting this error with nuxt 2.6.2

now.json

{
  "version": 2,
  "builds": [
    {
      "src": "nuxt.config.js",
      "use": "@nuxtjs/now-builder",
      "config": {}
    }
  ],
  "routes": [
    { "src": "/_nuxt/.+", "headers": { "cache-control": "s-maxage=31536000" } },
    { "src": "/(.*)", "dest": "/" }
  ]
}

[apollo] Cannot find module 'webpack-node-externals'

Error while initializing nuxt: { /var/task/node_modules/@nuxtjs/apollo/lib/module.js:1
Error: Cannot find module 'webpack-node-externals'
Require stack:
- /var/task/node_modules/@nuxtjs/apollo/lib/module.js
- /var/task/node_modules/@nuxt/core/dist/core.js
- /var/task/now__launcher.js
- /var/runtime/node_modules/awslambda/index.js
    at Proxy.<anonymous> (/var/task/node_modules/@sentry/node/dist/integrations/console.js:41:47)
    at Object.<anonymous> (/var/task/node_modules/@nuxtjs/apollo/lib/module.js:2:23)
  code: 'MODULE_NOT_FOUND',
  requireStack: 
   [ '/var/task/node_modules/@nuxtjs/apollo/lib/module.js',
     '/var/task/node_modules/@nuxt/core/dist/core.js',
     '/var/task/now__launcher.js',
     '/var/runtime/node_modules/awslambda/index.js' ] }

create-nuxt-app + now

Hi

If a use npx create-nuxt-app <project-name> (with options: npm, eslint, prettier) to scaffold a new Nuxt.js project and add the following now.json according to https://nuxtjs.org/faq/now-deployment

{
  "version": 2,
  "builds": [
    {
      "src": "nuxt.config.js",
      "use": "@nuxtjs/now-builder",
      "config": {}
    }
  ]
}

then that should be "all you have to do" according to the documentation, but when I deploy using now, I get the following in my browser:
Screenshot 2019-07-23 at 16 59 10

With the following log:

START RequestId: 324fe1b2-3c9c-4f42-96f8-f88a8d9224c4 Version: $LATEST
2019-07-23T06:43:43.706Z	324fe1b2-3c9c-4f42-96f8-f88a8d9224c4	λ Error while initializing nuxt: { /var/task/node_modules/@nuxt/core/dist/core.js:1
Error: Cannot find module '@nuxtjs/eslint-module'
Require stack:
- /var/task/node_modules/@nuxt/core/dist/core.js
- /var/task/now__launcher.js
- /var/runtime/node_modules/awslambda/index.js
    at Resolver.requireModule (/var/task/node_modules/@nuxt/core/dist/core.js:627:31)
    at ModuleContainer.addModule (/var/task/node_modules/@nuxt/core/dist/core.js:163:36)
    at promise.then (/var/task/node_modules/@nuxt/utils/dist/utils.js:1796:43)
    at <anonymous>
    at process._tickDomainCallback (internal/process/next_tick.js:228:7)
  code: 'MODULE_NOT_FOUND',
  requireStack: 
   [ '/var/task/node_modules/@nuxt/core/dist/core.js',
     '/var/task/now__launcher.js',
     '/var/runtime/node_modules/awslambda/index.js' ] }
END RequestId: 324fe1b2-3c9c-4f42-96f8-f88a8d9224c4
REPORT RequestId: 324fe1b2-3c9c-4f42-96f8-f88a8d9224c4	Duration: 46.36 ms	Billed Duration: 100 ms 	Memory Size: 3008 MB	Max Memory Used: 85 MB	
RequestId: 324fe1b2-3c9c-4f42-96f8-f88a8d9224c4 Process exited before completing request


START RequestId: 7bbc5115-d7b6-4a4d-8198-4d26f27667bd Version: $LATEST
2019-07-23T06:43:44.512Z	324fe1b2-3c9c-4f42-96f8-f88a8d9224c4	λ Error while initializing nuxt: { /var/task/node_modules/@nuxt/core/dist/core.js:1
Error: Cannot find module '@nuxtjs/eslint-module'
Require stack:
- /var/task/node_modules/@nuxt/core/dist/core.js
- /var/task/now__launcher.js
- /var/runtime/node_modules/awslambda/index.js
    at Resolver.requireModule (/var/task/node_modules/@nuxt/core/dist/core.js:627:31)
    at ModuleContainer.addModule (/var/task/node_modules/@nuxt/core/dist/core.js:163:36)
    at promise.then (/var/task/node_modules/@nuxt/utils/dist/utils.js:1796:43)
    at <anonymous>
    at process._tickDomainCallback (internal/process/next_tick.js:228:7)
  code: 'MODULE_NOT_FOUND',
  requireStack: 
   [ '/var/task/node_modules/@nuxt/core/dist/core.js',
     '/var/task/now__launcher.js',
     '/var/runtime/node_modules/awslambda/index.js' ] }
END RequestId: 7bbc5115-d7b6-4a4d-8198-4d26f27667bd
REPORT RequestId: 7bbc5115-d7b6-4a4d-8198-4d26f27667bd	Duration: 51.77 ms	Billed Duration: 100 ms 	Memory Size: 3008 MB	Max Memory Used: 46 MB	
RequestId: 7bbc5115-d7b6-4a4d-8198-4d26f27667bd Process exited before completing request


START RequestId: 323be968-e67f-43db-b23c-528c5d11a895 Version: $LATEST
2019-07-23T06:49:44.156Z	7bbc5115-d7b6-4a4d-8198-4d26f27667bd	λ Error while initializing nuxt: { /var/task/node_modules/@nuxt/core/dist/core.js:1
Error: Cannot find module '@nuxtjs/eslint-module'
Require stack:
- /var/task/node_modules/@nuxt/core/dist/core.js
- /var/task/now__launcher.js
- /var/runtime/node_modules/awslambda/index.js
    at Resolver.requireModule (/var/task/node_modules/@nuxt/core/dist/core.js:627:31)
    at ModuleContainer.addModule (/var/task/node_modules/@nuxt/core/dist/core.js:163:36)
    at promise.then (/var/task/node_modules/@nuxt/utils/dist/utils.js:1796:43)
    at <anonymous>
    at process._tickDomainCallback (internal/process/next_tick.js:228:7)
  code: 'MODULE_NOT_FOUND',
  requireStack: 
   [ '/var/task/node_modules/@nuxt/core/dist/core.js',
     '/var/task/now__launcher.js',
     '/var/runtime/node_modules/awslambda/index.js' ] }
END RequestId: 323be968-e67f-43db-b23c-528c5d11a895
REPORT RequestId: 323be968-e67f-43db-b23c-528c5d11a895	Duration: 39.97 ms	Billed Duration: 100 ms 	Memory Size: 3008 MB	Max Memory Used: 47 MB	
RequestId: 323be968-e67f-43db-b23c-528c5d11a895 Process exited before completing request


START RequestId: 5e420f1b-ee5e-459e-a668-1b3975e983dc Version: $LATEST
2019-07-23T06:49:48.813Z	323be968-e67f-43db-b23c-528c5d11a895	λ Error while initializing nuxt: { /var/task/node_modules/@nuxt/core/dist/core.js:1
Error: Cannot find module '@nuxtjs/eslint-module'
Require stack:
- /var/task/node_modules/@nuxt/core/dist/core.js
- /var/task/now__launcher.js
- /var/runtime/node_modules/awslambda/index.js
    at Resolver.requireModule (/var/task/node_modules/@nuxt/core/dist/core.js:627:31)
    at ModuleContainer.addModule (/var/task/node_modules/@nuxt/core/dist/core.js:163:36)
    at promise.then (/var/task/node_modules/@nuxt/utils/dist/utils.js:1796:43)
    at <anonymous>
    at process._tickDomainCallback (internal/process/next_tick.js:228:7)
  code: 'MODULE_NOT_FOUND',
  requireStack: 
   [ '/var/task/node_modules/@nuxt/core/dist/core.js',
     '/var/task/now__launcher.js',
     '/var/runtime/node_modules/awslambda/index.js' ] }
END RequestId: 5e420f1b-ee5e-459e-a668-1b3975e983dc
REPORT RequestId: 5e420f1b-ee5e-459e-a668-1b3975e983dc	Duration: 43.76 ms	Billed Duration: 100 ms 	Memory Size: 3008 MB	Max Memory Used: 46 MB	
RequestId: 5e420f1b-ee5e-459e-a668-1b3975e983dc Process exited before completing request


START RequestId: c2aa777b-673c-4c85-95d1-2c81c21197c1 Version: $LATEST
2019-07-23T06:49:49.494Z	5e420f1b-ee5e-459e-a668-1b3975e983dc	λ Error while initializing nuxt: { /var/task/node_modules/@nuxt/core/dist/core.js:1
Error: Cannot find module '@nuxtjs/eslint-module'
Require stack:
- /var/task/node_modules/@nuxt/core/dist/core.js
- /var/task/now__launcher.js
- /var/runtime/node_modules/awslambda/index.js
    at Resolver.requireModule (/var/task/node_modules/@nuxt/core/dist/core.js:627:31)
    at ModuleContainer.addModule (/var/task/node_modules/@nuxt/core/dist/core.js:163:36)
    at promise.then (/var/task/node_modules/@nuxt/utils/dist/utils.js:1796:43)
    at <anonymous>
    at process._tickDomainCallback (internal/process/next_tick.js:228:7)
  code: 'MODULE_NOT_FOUND',
  requireStack: 
   [ '/var/task/node_modules/@nuxt/core/dist/core.js',
     '/var/task/now__launcher.js',
     '/var/runtime/node_modules/awslambda/index.js' ] }
END RequestId: c2aa777b-673c-4c85-95d1-2c81c21197c1
REPORT RequestId: c2aa777b-673c-4c85-95d1-2c81c21197c1	Duration: 42.43 ms	Billed Duration: 100 ms 	Memory Size: 3008 MB	Max Memory Used: 46 MB	
RequestId: c2aa777b-673c-4c85-95d1-2c81c21197c1 Process exited before completing request


START RequestId: eae04864-257d-486d-b645-62c9957dd120 Version: $LATEST
2019-07-23T06:59:02.898Z	c2aa777b-673c-4c85-95d1-2c81c21197c1	λ Error while initializing nuxt: { /var/task/node_modules/@nuxt/core/dist/core.js:1
Error: Cannot find module '@nuxtjs/eslint-module'
Require stack:
- /var/task/node_modules/@nuxt/core/dist/core.js
- /var/task/now__launcher.js
- /var/runtime/node_modules/awslambda/index.js
    at Resolver.requireModule (/var/task/node_modules/@nuxt/core/dist/core.js:627:31)
    at ModuleContainer.addModule (/var/task/node_modules/@nuxt/core/dist/core.js:163:36)
    at promise.then (/var/task/node_modules/@nuxt/utils/dist/utils.js:1796:43)
    at <anonymous>
    at process._tickDomainCallback (internal/process/next_tick.js:228:7)
  code: 'MODULE_NOT_FOUND',
  requireStack: 
   [ '/var/task/node_modules/@nuxt/core/dist/core.js',
     '/var/task/now__launcher.js',
     '/var/runtime/node_modules/awslambda/index.js' ] }
END RequestId: eae04864-257d-486d-b645-62c9957dd120
REPORT RequestId: eae04864-257d-486d-b645-62c9957dd120	Duration: 48.49 ms	Billed Duration: 100 ms 	Memory Size: 3008 MB	Max Memory Used: 47 MB	
RequestId: eae04864-257d-486d-b645-62c9957dd120 Process exited before completing request


START RequestId: 418e79c8-594e-4e00-b08d-7d34686d54df Version: $LATEST
2019-07-23T06:59:03.321Z	eae04864-257d-486d-b645-62c9957dd120	λ Error while initializing nuxt: { /var/task/node_modules/@nuxt/core/dist/core.js:1
Error: Cannot find module '@nuxtjs/eslint-module'
Require stack:
- /var/task/node_modules/@nuxt/core/dist/core.js
- /var/task/now__launcher.js
- /var/runtime/node_modules/awslambda/index.js
    at Resolver.requireModule (/var/task/node_modules/@nuxt/core/dist/core.js:627:31)
    at ModuleContainer.addModule (/var/task/node_modules/@nuxt/core/dist/core.js:163:36)
    at promise.then (/var/task/node_modules/@nuxt/utils/dist/utils.js:1796:43)
    at <anonymous>
    at process._tickDomainCallback (internal/process/next_tick.js:228:7)
  code: 'MODULE_NOT_FOUND',
  requireStack: 
   [ '/var/task/node_modules/@nuxt/core/dist/core.js',
     '/var/task/now__launcher.js',
     '/var/runtime/node_modules/awslambda/index.js' ] }
END RequestId: 418e79c8-594e-4e00-b08d-7d34686d54df
REPORT RequestId: 418e79c8-594e-4e00-b08d-7d34686d54df	Duration: 39.79 ms	Billed Duration: 100 ms 	Memory Size: 3008 MB	Max Memory Used: 46 MB	
RequestId: 418e79c8-594e-4e00-b08d-7d34686d54df Process exited before completing request

What is the difference between @nuxt/now-builder and @now/static-builder

What is the difference between @nuxt/now-builder and @now/static-builder?

I am using @now/static-builder right now and have no issues since it points to the package.json file.

I was curious about the benefits of using this builder over the Zeit official builder. Additionally, it may be helpful to show these differences in the Readme.md.

Now deployment failing

I am running into deployment issues with the now-builder. I have other projects deployed just fine which is really throwing me off here.

Here is my nuxt.config.js:

const pkg = require('./package')
console.log('ENV', process.env.NODE_ENV)

module.exports = {
  mode: 'universal',
  router: { base: process.env.NODE_ENV === 'production' ? '/nuxt-argon-dashboard-pro/' : '' },
  head: {
    title: pkg.name,
    meta: [
      { charset: 'utf-8' },
      { name: 'viewport', content: 'width=device-width, initial-scale=1' },
      { hid: 'description', name: 'description', content: pkg.description }
    ],
    link: [
      { rel: 'icon', type: 'image/png', href: 'favicon.png' },
      { rel: 'stylesheet', href: 'https://fonts.googleapis.com/css?family=Open+Sans:300,400,600,700'},
      { rel: 'stylesheet', href: 'https://use.fontawesome.com/releases/v5.6.3/css/all.css', integrity: "sha384-UHRtZLI+pbxtHCWp1t77Bi1L4ZtiqrqD80Kn4Z8NTSRyMA2Fd33n5dQ8lWUE00s/", crossorigin: "anonymous"}
    ]
  },
  loading: { color: '#fff' },
  css: [
    'assets/css/nucleo/css/nucleo.css',
    'assets/sass/argon.scss'
  ],
  plugins: [
    '~/plugins/dashboard/dashboard-plugin',
  ],
  modules: [
    // Doc: https://axios.nuxtjs.org/usage
    '@nuxtjs/axios',
    '@nuxtjs/pwa',
  ],
  axios: {
    // See https://github.com/nuxt-community/axios-module#options
  },
  build: {
    extend(config, ctx) {
    },
    extractCSS: true,
    babel: {
      plugins: [
        [
          "component",
          {
            "libraryName": "element-ui",
            "styleLibraryName": "theme-chalk"
          }
        ]
      ]
    }
  }
}

Here is my package.json:

{
  "name": "Nuxt-Argon-Dashboard-PRO",
  "version": "1.0.0",
  "description": "Nuxt Dashboard",
  "author": "Wayne",
  "private": true,
  "scripts": {
    "dev": "nuxt",
    "build": "nuxt build",
    "start": "nuxt start",
    "generate": "nuxt generate"
  },
  "dependencies": {
    "@babel/core": "^7.4.5",
    "@fullcalendar/core": "^4.2.0",
    "@fullcalendar/daygrid": "^4.1.0",
    "@fullcalendar/interaction": "^4.1.0",
    "@fullcalendar/timegrid": "^4.1.0",
    "@fullcalendar/vue": "^4.2.2",
    "@nuxtjs/axios": "^5.3.6",
    "@nuxtjs/pwa": "^3.0.0-beta.16",
    "bootstrap": "^4.3.1",
    "chart.js": "^2.8.0",
    "d3": "^5.9.2",
    "datamaps": "^0.5.9",
    "date-fns": "^1.30.1",
    "dropzone": "^5.5.1",
    "element-ui": "^2.9.1",
    "es6-promise": "^4.2.6",
    "flatpickr": "^4.5.7",
    "fuse.js": "^3.4.5",
    "google-maps": "^3.3.0",
    "nouislider": "^13.1.5",
    "nuxt": "^2.8.1",
    "perfect-scrollbar": "^1.4.0",
    "quill": "^1.3.6",
    "sweetalert2": "^8.11.6",
    "vee-validate": "^2.2.8",
    "vue": "^2.6.10",
    "vue-chartjs": "^3.4.2",
    "vue-clipboard2": "^0.3.0",
    "vue-flatpickr-component": "^8.1.2",
    "vue2-transitions": "^0.3.0"
  },
  "devDependencies": {
    "babel-plugin-component": "^1.1.0",
    "cross-env": "^5.2.0",
    "node-sass": "^4.12.0",
    "nodemon": "^1.18.9",
    "sass-loader": "^7.1.0"
  }
}

Here is my now.json:

{
  "version": 2,
  "builds": [
    {
      "src": "nuxt.config.js",
      "use": "@nuxtjs/now-builder",
      "config": {}
    }
  ],
  "routes": [
    {
      "src": "/_nuxt/.+",
      "headers": {
        "cache-control": "s-maxage=31536000"
      }
    },
    {
      "src": "/(.*)",
      "dest": "/"
    }
  ]
}

Lastly the Now logs:

tput: No value for $TERM and no -T specified

   ╭─────────────────────────────╮
   │                             │
   │   ✖ Nuxt Fatal Error        │
   │                             │
   │   Error: Nuxt Build Error   │
   │                             │
   ╰─────────────────────────────╯

{ Error: Command failed: nuxt build --standalone --no-lock --config-file "nuxt.config.js"
null
null
    at makeError (/tmp/252ea55a36e2b1b6/.build-utils/.builder/node_modules/execa/index.js:174:9)
    at Promise.all.then.arr (/tmp/252ea55a36e2b1b6/.build-utils/.builder/node_modules/execa/index.js:278:16)
    at <anonymous>
    at process._tickDomainCallback (internal/process/next_tick.js:228:7)
  code: 1,
  stdout: null,
  stderr: null,
  failed: true,
  signal: null,
  cmd: 'nuxt build --standalone --no-lock --config-file "nuxt.config.js"',
  timedOut: false,
  killed: false }

I've seen the execa causing error in a few posts: (#73), (#46) and (#18). It's not a direct dependency of my project so I am not sure what to do here, and I haven't seen a clear answer on what to do in the three aforementioned issues.

Apologies in advance if I am forgetting something obvious. Let me know if I can provide anything else, any help is greatly appreciated!

handle `static/` assets with CDN

Currently, if static/ assets are not included in the lambda, won't be served correctly. Returning a 404 error code:

curl -I https://example-px2tsp4l9.now.sh/test.txt
HTTP/2 404 
date: Sat, 23 Feb 2019 16:59:38 GMT
content-type: text/plain
vary: Accept-Encoding
cache-control: s-maxage=0
x-now-trace: sfo1
server: now
now: 1

We need a rule in the routes section of now.json to catch routes for *.* pattern correctly and prevent fallback to the lambda.

NOTE: Builder is supporting static/ assets. This is an enhancement issue!

Different node versions support

It is stated that @nuxt/now-builder only support node@8.

Is it possible to use other versions? 8 is not even the last LTE.

@nuxtjs/auth module options do not seem to work in production

I'm using @nuxtjs/auth module for authentication and I have a login page with auth: 'guest' option. It means, that the page is visible only for guests (if this.$auth.loggedIn is false). But in production I can still visit the page while being authenticated. Does this have something to do with deployment configuration?

UPD:

I added custom middleware where I check loggedIn status and then redirect if it's true.
But I've not declared that middleware globally. I declared it only for specific pages as component option. And these options are being ignored in production.

Server Middleware not included in lambda

I'm getting this error: λ Error while initializing nuxt: { Error: Cannot find module './api/auth'

I am just not sure how to get my API middleware files included in the lambda. Is that something I need to do in the now config or in nuxt config? File lives at ~/api/auth and is included in next.config like this: serverMiddleware: ['~/api/auth'],.

Error: Cannot find module 'svg-to-vue-component/nuxt'

Hi 👋 ,
I'm trying to deploy to Now 2 with @nuxtjs/now-builder and get this error:

λ Error while initializing nuxt: { /var/task/node_modules/@nuxt/core/dist/core.js:1
Error: Cannot find module 'svg-to-vue-component/nuxt'
Require stack:
- /var/task/node_modules/@nuxt/core/dist/core.js
- /var/task/now__launcher.js
- /var/runtime/node_modules/awslambda/index.js
    at Resolver.requireModule (/var/task/node_modules/@nuxt/core/dist/core.js:627:31)
    at ModuleContainer.addModule (/var/task/node_modules/@nuxt/core/dist/core.js:163:36)
    at promise.then (/var/task/node_modules/@nuxt/utils/dist/utils.js:1796:43)
    at <anonymous>
    at process._tickDomainCallback (internal/process/next_tick.js:228:7)
  code: 'MODULE_NOT_FOUND',

now.json is basically copy-pasted from here.

svg-to-vue component is cofigured as suggested.

No issues locally or deploying to netlify with nuxt generate.

I assume this could be an issue with the 'nested' module naming? 🤔
Or is it actually the fault of svg-to-vue-component?

Does extendRoutes work?

Hi!

I have been using Nuxt as a Blog platform and have a need to render many different URL structures using the same template, for example here's my Nuxt.config entry:

 router: {
    extendRoutes (routes, resolve) {
      routes.push({ name: '_page', path: '/:page', component: resolve(__dirname, 'pages/static.vue') })
      routes.push({ name: '_page_id', path: '/:page/:id', component: resolve(__dirname, 'pages/static.vue') })
      routes.push({ name: '_page_id_slug', path: '/:page/:id/:slug', component: resolve(__dirname, 'pages/static.vue') })
    }
  },

I am currently having trouble deploying this application to Now and not sure if the builder is the culprit or something else. Have you seen any problems with using extendRoutes and this builder?

Barebone nuxt project on ZEIT now

Hi there,

so I've set up a barebone new project to create a reproducible use case for this issue but I've found more errors, so I opened this new issue.
Here's what I did and found:

Steps:

  1. $ yarn create nuxt-app <project-name> - as per the Get Started Guide
  2. create now.json with the config copied from this repos README
  3. now

Issue 1: Gets already a Build Error on ZEIT, Error: nuxt >= 2.4.0 is required mentioned in this issue.
That's fixed by running yarn add nuxt again. After that, the build on ZEIT works and the deployment is successful. But:

Issue 2: That deployment has an application error.
Logs say Cannot find module '@nuxtjs/eslint-module' mentioned in this issue
The Fix is mentioned in there but not yet released in nuxt from what I can see.

After fixing that and deploying again through now, I get a working application:
https://ssr-zeit-firebase-7ia9s0c1a.now.sh

Then, I add Firebase via yarn add firebase. I've imported Firebase into the store and calling a simple action just to make sure it's used in the application.

Issue 3: It works fine in spa mode but universal throws a build error on ZEIT that works fine locally.

You can find the deployment here and the repository here (I have deleted my firebase credentials in helper/initFirebase).

Logs:


TaskID d77bf844-0ff3-4fbc-9937-2e6ac233a81d
@zeit/now-dcs-info: using https://dcs.now.systems as the upstream
running yarn for @now/build-utils@latest...
yarn add v1.16.0
info No lockfile found.
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...
success Saved lockfile.
success Saved 41 new dependencies.
info Direct dependencies
└─ @now/[email protected]
info All dependencies
├─ @now/[email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
└─ [email protected]
Done in 0.82s.
running yarn for @nuxtjs/now-builder...
yarn add v1.16.0
info No lockfile found.
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...
success Saved lockfile.
success Saved 27 new dependencies.
info Direct dependencies
└─ @nuxtjs/[email protected]
info All dependencies
├─ @now/[email protected]
├─ @nuxtjs/[email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
└─ [email protected]
Done in 2.23s.
running builder.exports.build...
 ----------------- Prepare build ----------------- 
Entry directory: .
Downloading files...
Working directory: /tmp/3559a3cc
Using yarn
ℹ Prepare build took: 1972.583248 ms
 ----------------- Install devDependencies ----------------- 
Running yarn install --prefer-offline --frozen-lockfile --non-interactive --production=false --cache-folder=/tmp/3559a3cc/.now_cache/yarn
yarn install v1.16.0
[1/5] Resolving packages...
success Already up-to-date.
Done in 0.63s.
ℹ Install devDependencies took: 962.793956 ms
 ----------------- Nuxt build ----------------- 

 WARN  .nuxt exists! Please ensure to ignore it with .nowignore

Running nuxt build --standalone --no-lock --config-file "nuxt.config.js"
ℹ Production build
✔ Builder initialized
✔ Nuxt files generated
ℹ Compiling Client
✔ Client: Compiled successfully in 14.31s
ℹ Compiling Server
✔ Server: Compiled with some errors in 18.62s

Hash: �[1me4cc6deab91ed2a896f8�[39m�[22m
Version: webpack �[1m4.35.3�[39m�[22m
Time: �[1m18632�[39m�[22mms
Built at: 2019-07-10 �[1m08:50:00�[39m�[22m
                  �[1mAsset�[39m�[22m      �[1mSize�[39m�[22m  �[1mChunks�[39m�[22m  �[1m�[39m�[22m�[1m�[39m�[22m�[1mChunk Names�[39m�[22m
               �[1m�[32mLICENSES�[39m�[22m  6.57 KiB        �[1m�[39m�[22m  �[1m�[32m�[39m�[22m
�[1m�[32ma50bf8049f4a326dd909.js�[39m�[22m  3.72 KiB       �[1m1�[39m�[22m  �[1m�[32m�[39m�[22mpages/index
              �[1m�[32mserver.js�[39m�[22m   1.6 MiB       �[1m0�[39m�[22m  �[1m�[32m�[39m�[22mapp
 + 2 hidden assets
Entrypoint �[1mapp�[39m�[22m = �[1m�[32mserver.js�[39m�[22m �[1m�[32mserver.js.map�[39m�[22m

�[1m�[33mWARNING in ./node_modules_dev/grpc/src/grpc_extension.js 32:12-33
Critical dependency: the request of a dependency is an expression
 @ ./node_modules_dev/grpc/index.js
 @ ./node_modules_dev/@firebase/firestore/dist/index.node.cjs.js
 @ ./node_modules_dev/firebase/dist/index.node.cjs.js
 @ ./helper/initFirebase.js
 @ ./store/index.js
 @ ./.nuxt/store.js
 @ ./.nuxt/index.js
 @ ./.nuxt/server.js
 @ multi ./.nuxt/server.js�[39m�[22m

�[1m�[33mWARNING in ./node_modules_dev/grpc/node_modules/node-pre-gyp/lib/pre-binding.js 20:22-48
Critical dependency: the request of a dependency is an expression
 @ ./node_modules_dev/grpc/src/grpc_extension.js
 @ ./node_modules_dev/grpc/index.js
 @ ./node_modules_dev/@firebase/firestore/dist/index.node.cjs.js
 @ ./node_modules_dev/firebase/dist/index.node.cjs.js
 @ ./helper/initFirebase.js
 @ ./store/index.js
 @ ./.nuxt/store.js
 @ ./.nuxt/index.js
 @ ./.nuxt/server.js
 @ multi ./.nuxt/server.js�[39m�[22m

�[1m�[33mWARNING in ./node_modules_dev/grpc/node_modules/node-pre-gyp/lib/util/versioning.js 17:20-67
Critical dependency: the request of a dependency is an expression
 @ ./node_modules_dev/grpc/node_modules/node-pre-gyp/lib/pre-binding.js
 @ ./node_modules_dev/grpc/src/grpc_extension.js
 @ ./node_modules_dev/grpc/index.js
 @ ./node_modules_dev/@firebase/firestore/dist/index.node.cjs.js
 @ ./node_modules_dev/firebase/dist/index.node.cjs.js
 @ ./helper/initFirebase.js
 @ ./store/index.js
 @ ./.nuxt/store.js
 @ ./.nuxt/index.js
 @ ./.nuxt/server.js
 @ multi ./.nuxt/server.js�[39m�[22m

�[1m�[33mWARNING in ./node_modules_dev/encoding/lib/iconv-loader.js 9:12-34
Critical dependency: the request of a dependency is an expression
 @ ./node_modules_dev/encoding/lib/encoding.js
 @ ./node_modules_dev/isomorphic-fetch/node_modules/node-fetch/lib/body.js
 @ ./node_modules_dev/isomorphic-fetch/node_modules/node-fetch/index.js
 @ ./node_modules_dev/isomorphic-fetch/fetch-npm-node.js
 @ ./node_modules_dev/@firebase/functions/dist/index.node.cjs.js
 @ ./node_modules_dev/firebase/dist/index.node.cjs.js
 @ ./helper/initFirebase.js
 @ ./store/index.js
 @ ./.nuxt/store.js
 @ ./.nuxt/index.js
 @ ./.nuxt/server.js
 @ multi ./.nuxt/server.js�[39m�[22m

�[1m�[33mWARNING in ./node_modules_dev/bytebuffer/dist/bytebuffer-node.js
Module not found: Error: Can't resolve 'memcpy' in '/tmp/3559a3cc/node_modules_dev/bytebuffer/dist'
 @ ./node_modules_dev/bytebuffer/dist/bytebuffer-node.js
 @ ./node_modules_dev/protobufjs/dist/protobuf.js
 @ ./node_modules_dev/@firebase/firestore/dist/index.node.cjs.js
 @ ./node_modules_dev/firebase/dist/index.node.cjs.js
 @ ./helper/initFirebase.js
 @ ./store/index.js
 @ ./.nuxt/store.js
 @ ./.nuxt/index.js
 @ ./.nuxt/server.js
 @ multi ./.nuxt/server.js�[39m�[22m

�[1m�[31mERROR in ./node_modules_dev/@firebase/database/dist/index.node.cjs.js
Module not found: Error: Can't resolve 'request' in '/tmp/3559a3cc/node_modules_dev/@firebase/database/dist'
 @ ./node_modules_dev/@firebase/database/dist/index.node.cjs.js 15512:135-153
 @ ./node_modules_dev/firebase/dist/index.node.cjs.js
 @ ./helper/initFirebase.js
 @ ./store/index.js
 @ ./.nuxt/store.js
 @ ./.nuxt/index.js
 @ ./.nuxt/server.js
 @ multi ./.nuxt/server.js�[39m�[22m

Hash: �[1m0be2714ddf8bc0a5f8ef�[39m�[22m
Version: webpack �[1m4.35.3�[39m�[22m
Time: �[1m14312�[39m�[22mms
Built at: 2019-07-10 �[1m08:49:41�[39m�[22m
                         �[1mAsset�[39m�[22m      �[1mSize�[39m�[22m  �[1mChunks�[39m�[22m  �[1m�[39m�[22m           �[1m�[39m�[22m       �[1mChunk Names�[39m�[22m
�[1m�[32m../server/client.manifest.json�[39m�[22m  7.85 KiB        �[1m�[39m�[22m  �[1m�[32m[emitted]�[39m�[22m         
       �[1m�[33m3046f6084a0f69d4f40b.js�[39m�[22m  �[1m�[33m1.17 MiB�[39m�[22m       �[1m0�[39m�[22m  �[1m�[32m[emitted]�[39m�[22m  �[1m�[33m[big]�[39m�[22m  app
                      �[1m�[32mLICENSES�[39m�[22m   3.1 KiB        �[1m�[39m�[22m  �[1m�[32m[emitted]�[39m�[22m         
       �[1m�[32ma2a8647a113e53aee573.js�[39m�[22m  2.26 KiB       �[1m2�[39m�[22m  �[1m�[32m[emitted]�[39m�[22m         runtime
       �[1m�[32mcd9c163fbea42d82bb5d.js�[39m�[22m  3.66 KiB       �[1m1�[39m�[22m  �[1m�[32m[emitted]�[39m�[22m         pages/index
 + 2 hidden assets
Entrypoint �[1mapp�[39m�[22m �[1m�[33m[big]�[39m�[22m = �[1m�[32ma2a8647a113e53aee573.js�[39m�[22m �[1m�[32m3046f6084a0f69d4f40b.js�[39m�[22m

�[1m�[33mWARNING in asset size limit: The following asset(s) exceed the recommended size limit (244 KiB).
This can impact web performance.
Assets: 
  3046f6084a0f69d4f40b.js (1.17 MiB)�[39m�[22m

�[1m�[33mWARNING in entrypoint size limit: The following entrypoint(s) combined asset size exceeds the recommended limit (1000 KiB). This can impact web performance.
Entrypoints:
  app (1.17 MiB)
      a2a8647a113e53aee573.js
      3046f6084a0f69d4f40b.js
�[39m�[22m

 FATAL  Nuxt Build Error

  at WebpackBundler.webpackCompile (node_modules_dev/@nuxt/webpack/dist/webpack.js:5367:13)
  at <anonymous>
  at process._tickDomainCallback (internal/process/next_tick.js:228:7)

tput: No value for $TERM and no -T specified

   ╭─────────────────────────────╮
   │                             │
   │   ✖ Nuxt Fatal Error        │
   │                             │
   │   Error: Nuxt Build Error   │
   │                             │
   ╰─────────────────────────────╯

{ Error: Command failed: nuxt build --standalone --no-lock --config-file "nuxt.config.js"
null
null
    at makeError (/tmp/7ca7e0dc/.build-utils/.builder/node_modules/execa/index.js:174:9)
    at Promise.all.then.arr (/tmp/7ca7e0dc/.build-utils/.builder/node_modules/execa/index.js:278:16)
    at <anonymous>
    at process._tickDomainCallback (internal/process/next_tick.js:228:7)
  code: 1,
  stdout: null,
  stderr: null,
  failed: true,
  signal: null,
  cmd: 'nuxt build --standalone --no-lock --config-file "nuxt.config.js"',
  timedOut: false,
  killed: false }

Hope this helps!

Now deployment fails

Unfortunately when deploying to Now I get a Fatal Error with no other messages.

2019-05-09T12:53:18.284Z     ╭─────────────────────────────╮
                             │                             │
                             │   ✖ Nuxt Fatal Error        │
                             │                             │
                             │   Error: Nuxt Build Error   │
                             │                             │
                             ╰─────────────────────────────╯
2019-05-09T12:53:18.317Z  { Error: Command failed: nuxt build --standalone --no-lock --config-file "nuxt.config.js"
                          null
                          null
                              at makeError (/tmp/utils/build-module/node_modules/execa/index.js:174:9)
                              at Promise.all.then.arr (/tmp/utils/build-module/node_modules/execa/index.js:278:16)
                              at <anonymous>
                              at process._tickDomainCallback (internal/process/next_tick.js:228:7)
                            code: 1,
                            stdout: null,
                            stderr: null,
                            failed: true,
                            signal: null,
                            cmd: 'nuxt build --standalone --no-lock --config-file "nuxt.config.js"',
                            timedOut: false,
                            killed: false }

My now.json file is...

{
  "version": 2,
  "builds": [
    {
      "src": "nuxt.config.js",
      "use": "@nuxtjs/now-builder",
      "config": {}
    }
  ],
  "routes": [
    { "src": "/_nuxt/.+", "headers": { "cache-control": "s-maxage=31536000" } },
    { "src": "/(.*)", "dest": "/" }
  ]
}

I'm running Nuxt version 2.6.3 and my local build works perfectly. I've tried running nuxt build --standalone --no-lock --config-file "nuxt.config.js" which works locally too.

Any ideas?

TypeError: pkg.dependencies.includes is not a function

About 30 min ago it's started occur this error:

TypeError: pkg.dependencies.includes is not a function
Aug 30 2019 17:05:50:834 | ...nuxt.config.js | at Object.build (/tmp/0bdc61dff64f6481/.build-utils/.builder/node_modules/@nuxtjs/now-builder/lib/build.js:44:64)
Aug 30 2019 17:05:50:834 | ...nuxt.config.js |  

Maybe is because of the new release @pi0?

PS: My build is working on development.

now-builder is not compatible with yarn workspaces

I've been testing out @nuxt/now-builder with yarn workspace features. It installs packages correctly and runs nuxt build successfully successfully. There are no build-time errors.

(The build command is yarn install --prefer-offline --pure-lockfile --non-interactive --production=true --cache-folder=/tmp/{project root}/{workspace subdirectory}/.now_cache/yarn)

However, node_modules is not then included in the resulting lambda (1Mb vs ~25Mb).

The following is the run-time error that occurs:

{
  "errorType": "Runtime.ImportModuleError",
  "errorMessage": "Error: Cannot find module 'esm'",
  "stack": [
    "Runtime.ImportModuleError: Error: Cannot find module 'esm'",
    "    at _loadUserApp (/var/runtime/UserFunction.js:100:13)",
    "    at Object.module.exports.load (/var/runtime/UserFunction.js:140:17)",
    "    at Object.<anonymous> (/var/runtime/index.js:36:30)",
    "    at Module._compile (internal/modules/cjs/loader.js:776:30)",
    "    at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10)",
    "    at Module.load (internal/modules/cjs/loader.js:653:32)",
    "    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)",
    "    at Function.Module._load (internal/modules/cjs/loader.js:585:3)",
    "    at Function.Module.runMain (internal/modules/cjs/loader.js:829:12)",
    "    at startup (internal/bootstrap/node.js:283:19)"
  ]
}

ReferenceError: build is not defined

Fails with the following error messages.
I'd appreciate if you could advise.

/tmp/utils/build-module/node_modules/@nuxtjs/now-builder/lib/build.js:102
ReferenceError: build is not defined
    at Object.build (/tmp/utils/build-module/node_modules/@nuxtjs/now-builder/lib/build.js:102:38)
    at <anonymous>
    at process._tickDomainCallback (internal/process/next_tick.js:228:7)

Here's my now.json

{
  "name": "testapp",
  "version": 2,
  "builds": [
    {
      "src": "nuxt.config.js",
      "use": "@nuxtjs/now-builder",
      "config": {
        "serverFiles": [
          "servermiddleware/**"
        ]
      }
    }
  ],
  "routes": [
    { "src": "/_nuxt/.+", "headers": { "cache-control": "s-maxage=31536000" } },
    { "src": "/(.*)", "dest": "/" }
  ]
}

[nuxt-i18n] Error: Cannot find module 'vue-template-compiler'

The Nuxt.js app deploys, but I get the following error in my Output logs:

λ Error while initializing nuxt: { /var/task/node_modules/nuxt-i18n/src/helpers/components.js:1
Error: Cannot find module 'vue-template-compiler'
Require stack:
- /var/task/node_modules/nuxt-i18n/src/helpers/components.js
- /var/task/node_modules/nuxt-i18n/src/helpers/routes.js
- /var/task/node_modules/nuxt-i18n/src/index.js
- /var/task/node_modules/@nuxt/core/dist/core.js
- /var/task/now__launcher.js
- /var/runtime/node_modules/awslambda/index.js
    at Object.<anonymous> (/var/task/node_modules/nuxt-i18n/src/helpers/components.js:6:18)
    at Object.<anonymous> (/var/task/node_modules/nuxt-i18n/src/helpers/components.js:1)
  code: 'MODULE_NOT_FOUND',
  requireStack: 
   [ '/var/task/node_modules/nuxt-i18n/src/helpers/components.js',
     '/var/task/node_modules/nuxt-i18n/src/helpers/routes.js',
     '/var/task/node_modules/nuxt-i18n/src/index.js',
     '/var/task/node_modules/@nuxt/core/dist/core.js',
     '/var/task/now__launcher.js',
     '/var/runtime/node_modules/awslambda/index.js' ] }

Any idea how to fix this? Shouldn‘t vue-template-compiler be a core dependency of nuxt?

Some image assets are 404 but used to work fine.

I am using the nuxt builder for now and am unable to serve certain images that used to work. If I go to /_src I can see them in the file browser but I can't link to them. I didn't really change any code and feel like it could be a builder issue but I am not sure.

For example: https://tiltaing.tilta.com/media-assets/fade.jpg

On the live site, the image doesn't load https://tiltaing.tilta.com

on an old deploy it does https://tiltaing-nuxt-8psyzmwiy.now.sh/
i changed the url to try to get it to work but no luck. https://tiltaing-nuxt-8psyzmwiy.now.sh/fade.jpg loads correctly.

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.