nuxt / vercel-builder

Vercel Builder for Nuxt
MIT License
645 stars 76 forks source link

Nuxt.js Internal Server Error with firebase #41

Closed dowdiness closed 5 years ago

dowdiness commented 5 years ago

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?

pi0 commented 5 years ago

@dowdiness Please consider not exposing apiKey in a public repository.

Can you please share the link of your deployment? Logs are accessible with /_logs

MarvinMiles commented 5 years ago

As I figured out, this error caused by importing submodule in second line:

import { firebase } from '@firebase/app'
import '@firebase/firestore'

Temporary way to solve this might be importing firebase-admin for SSR and submodules for Client Side. But I haven't tested it yet.

ZackPashkin commented 5 years ago

Having the same issue

MarvinMiles commented 5 years ago

I have fixed it by adding firebase packages into webpack externals as CommonJS modules in nuxt.config file for SSR bundle:

 build: {
    extend ( config, { isDev, isClient, isServer } ) {
      if ( isServer ) {
        config.externals = {
          '@firebase/app': 'commonjs @firebase/app',
          '@firebase/firestore': 'commonjs @firebase/firestore',
          //etc...
        }
      }
    }
}

So glad I finally managed it out. Hope it will help anyone else

codeofsumit commented 5 years ago

Same issue here.

@MarvinMiles can you elaborate on your solution? It doesn't work for me but if I'm able to understand it, I might be able to come up with something myself. What exactly is the issue here? Is it Firebase? Or Nuxt? (or even ZEIT?) What causes that Problem?

Thank you for any hints!

codeofsumit commented 5 years ago

@Atinux I think this issue should be reopened. Using firebase breaks nuxt on ZEIT v2 and it doesn't seem there is an easy fix 🤔. I've switched to spa-mode for now until I find a solution. Can anyone tell me what the problem actually is?

This is the output from ZEIT when a request is made:

START RequestId: a18d2768-e654-4db7-960a-2d158e8fe660 Version: $LATEST
END RequestId: a18d2768-e654-4db7-960a-2d158e8fe660
REPORT RequestId: a18d2768-e654-4db7-960a-2d158e8fe660  
Duration: 9.00 ms  Billed Duration: 100 ms   Memory Size: 3008 MB  Max Memory Used: 138 MB  
START RequestId: 6b173cbb-2cf3-44a6-9b73-c52707ea1c76 Version: $LATEST
END RequestId: 6b173cbb-2cf3-44a6-9b73-c52707ea1c76
REPORT RequestId: 6b173cbb-2cf3-44a6-9b73-c52707ea1c76  
Duration: 3.39 ms  Billed Duration: 100 ms   Memory Size: 3008 MB  Max Memory Used: 138 MB  

Error: image

Failing Deployment example (private): https://www-ipr8pahmo.now.sh/

vimota commented 5 years ago

Was there a resolution to this issue?

danielroe commented 5 years ago

@vimota https://github.com/nuxt/now-builder/issues/41#issuecomment-494717072 resolves your issue.

codeofsumit commented 5 years ago

@danielroe that doesn't fix the issue for me at least.

danielroe commented 5 years ago

@codeofsumit It fixes your repro for me. https://ssr-zeit-firebase-h8vei5q9y.now.sh/

codeofsumit commented 5 years ago

Hm, will check again thank you!

vimota commented 5 years ago

It did indeed resolve my issues as well! Just curious, is that a bug or expected behaviour? I don't totally get why we have to add it to the externals config.

danielroe commented 5 years ago

I think this might be a reasonable explanation. for why firebase and lambda can cause problems.

lincolnlemos commented 4 years ago

Hey guys,

Are you guys using the now.json version 2? I got this message from the vercel build log:

Warning: Due to builds existing in your configuration file, the Build and Development Settings defined in your Project Settings will not apply. Learn More: https://vercel.link/unused-build-settings

So, it looks like the @MarvinMiles didn't apply.

Anyway, I'm still getting the error here.

14:00:58.006  Cloning gitlab.com/linciapp/linci-public (Branch: master, Commit: 15c7069)
14:00:59.104  Cloning completed in 1098ms
14:00:59.104  Analyzing source code...
14:00:59.105  Warning: Due to `builds` existing in your configuration file, the Build and Development Settings defined in your Project Settings will not apply. Learn More: https://vercel.link/unused-build-settings
14:01:00.116  Installing build runtime...
14:01:02.673  Build runtime installed: 2556.706ms
14:01:03.565   ----------------- Prepare build ----------------- 
14:01:03.565  Downloading files...
14:01:03.647  Working directory: /vercel/30aec542
14:01:03.649  Using npm
14:01:03.650  ℹ Prepare build took: 84.318644 ms
14:01:03.650   ----------------- Install devDependencies ----------------- 
14:01:03.651  Running npm install
14:01:40.665  > node-sass@4.14.1 install /vercel/30aec542/node_modules/node-sass
14:01:40.665  > node scripts/install.js
14:01:40.957  Downloading binary from https://github.com/sass/node-sass/releases/download/v4.14.1/linux-x64-72_binding.node
14:01:41.813  Download complete
14:01:41.817  Binary saved to /vercel/30aec542/node_modules_dev/node-sass/vendor/linux-x64-72/binding.node
14:01:41.852  Caching binary to /vercel/.npm/node-sass/4.14.1/linux-x64-72_binding.node
14:01:41.991  > core-js@3.6.5 postinstall /vercel/30aec542/node_modules/@firebase/polyfill/node_modules/core-js
14:01:41.991  > node -e "try{require('./postinstall')}catch(e){}"
14:01:42.053  Thank you for using core-js ( https://github.com/zloirock/core-js ) for polyfilling JavaScript standard library!
14:01:42.054  The project needs your help! Please consider supporting of core-js on Open Collective or Patreon: 
14:01:42.054  > https://opencollective.com/core-js 
14:01:42.054  > https://www.patreon.com/zloirock 
14:01:42.054  Also, the author of core-js ( https://github.com/zloirock ) is looking for a good job -)
14:01:42.149  > core-js@2.6.11 postinstall /vercel/30aec542/node_modules/core-js
14:01:42.149  > node -e "try{require('./postinstall')}catch(e){}"
14:01:42.213  Thank you for using core-js ( https://github.com/zloirock/core-js ) for polyfilling JavaScript standard library!
14:01:42.213  The project needs your help! Please consider supporting of core-js on Open Collective or Patreon: 
14:01:42.213  > https://opencollective.com/core-js 
14:01:42.213  > https://www.patreon.com/zloirock 
14:01:42.213  Also, the author of core-js ( https://github.com/zloirock ) is looking for a good job -)
14:01:42.242  > ejs@2.7.4 postinstall /vercel/30aec542/node_modules/ejs
14:01:42.242  > node ./postinstall.js
14:01:42.300  Thank you for installing EJS: built with the Jake JavaScript build tool (https://jakejs.com/)
14:01:42.544  > core-js@3.6.5 postinstall /vercel/30aec542/node_modules/plyr/node_modules/core-js
14:01:42.545  > node -e "try{require('./postinstall')}catch(e){}"
14:01:42.609  Thank you for using core-js ( https://github.com/zloirock/core-js ) for polyfilling JavaScript standard library!
14:01:42.609  The project needs your help! Please consider supporting of core-js on Open Collective or Patreon: 
14:01:42.609  > https://opencollective.com/core-js 
14:01:42.609  > https://www.patreon.com/zloirock 
14:01:42.609  Also, the author of core-js ( https://github.com/zloirock ) is looking for a good job -)
14:01:42.634  > protobufjs@6.9.0 postinstall /vercel/30aec542/node_modules/protobufjs
14:01:42.634  > node scripts/postinstall
14:01:43.076  > ant-design-vue@1.6.2 postinstall /vercel/30aec542/node_modules/ant-design-vue
14:01:43.076  > node scripts/postinstall || echo "ignore"
14:01:43.143  Thank you for using ant-design-vue ( https://github.com/vueComponent/ant-design-vue )!
14:01:43.144  The project needs your help! Please consider supporting of ant-design-vue on Open Collective or Patreon: 🙏
14:01:43.144  > https://opencollective.com/ant-design-vue 
14:01:43.144  > https://www.patreon.com/tangjinzhou 
14:01:43.144  更多赞助方式(支付宝、微信、Paypal)请查看如下链接: 🙏
14:01:43.144  > https://www.antdv.com/docs/vue/sponsor-cn 
14:01:43.144  Ant Design Vue 官方网站: 
14:01:43.144  > https://www.antdv.com/ 
14:01:43.152  > node-sass@4.14.1 postinstall /vercel/30aec542/node_modules/node-sass
14:01:43.152  > node scripts/build.js
14:01:43.304  Binary found at /vercel/30aec542/node_modules_dev/node-sass/vendor/linux-x64-72/binding.node
14:01:43.304  Testing binary
14:01:43.404  Binary is fine
14:01:43.409  > nuxt@2.13.0 postinstall /vercel/30aec542/node_modules/nuxt
14:01:43.409  > opencollective || exit 0
14:01:43.603                                                               
14:01:43.603                                       :-:                     
14:01:43.603                                     .==-+:                    
14:01:43.603                                    .==. :+- .-=-              
14:01:43.603                                   .==.   :==++-+=.            
14:01:43.603                                  :==.     -**: :+=.           
14:01:43.603                                 :+-      :*+++. .++.          
14:01:43.603                                :+-      -*= .++: .=+.         
14:01:43.603                               -+:      =*-   .+*: .=+:        
14:01:43.603                              -+:     .=*-     .=*-  =+:       
14:01:43.603                            .==:     .+*:        -*-  -+-      
14:01:43.603                           .=+:.....:+*-.........:=*=..=*-     
14:01:43.603                           .-=------=++============++====:     
14:01:43.603                                           
14:01:43.603                            Thanks for installing nuxtjs 
14:01:43.603                   Please consider donating to our open collective
14:01:43.603                          to help us maintain this package.
14:01:43.603                                           
14:01:43.603                             Number of contributors: 229
14:01:43.603                                Number of backers: 332
14:01:43.604                                Annual budget: $71,867
14:01:43.604                               Current balance: $23,135
14:01:43.604                                           
14:01:43.604                   Donate: https://opencollective.com/nuxtjs/donate
14:01:43.604                                           
14:01:45.235  npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.13 (node_modules/watchpack-chokidar2/node_modules/fsevents):
14:01:45.235  npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
14:01:45.235  npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.1.3 (node_modules/fsevents):
14:01:45.235  npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.1.3: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
14:01:45.241  added 1998 packages from 957 contributors and audited 2002 packages in 41.177s
14:01:46.539  118 packages are looking for funding
14:01:46.539    run `npm fund` for details
14:01:46.540  found 0 vulnerabilities
14:01:46.576  ℹ Install devDependencies took: 42925.207772 ms
14:01:46.576   ----------------- Nuxt build ----------------- 
14:01:46.601  Running nuxt build --standalone --no-lock --config-file "nuxt.config.js"
14:01:48.321  ℹ Production build
14:01:48.321  ℹ Bundling for server and client side
14:01:48.322  ℹ Target: server
14:01:48.333  ✔ Builder initialized
14:01:48.384  ✔ Nuxt files generated
14:01:49.896  ℹ Compiling Client
14:02:17.329  ✔ Client: Compiled successfully in 27.43s
14:02:17.334  ℹ Compiling Server
14:02:23.185  ✔ Server: Compiled successfully in 5.85s
14:02:23.186  Hash: 90ac07cd3ad6b6862748
14:02:23.187  Version: webpack 4.43.0
14:02:23.187  Time: 27435ms
14:02:23.187  Built at: 06/23/2020 5:02:17 PM
14:02:23.187                           Asset      Size  Chunks                                Chunk Names
14:02:23.187  ../server/client.manifest.json  42.4 KiB          [emitted]                     
14:02:23.187                    5.4983c5e.js   283 KiB       5  [emitted] [immutable]  [big]  
14:02:23.187                        LICENSES  4.66 KiB          [emitted]                     
14:02:23.187                  app.ec921b7.js   2.9 MiB       0  [emitted] [immutable]  [big]  app
14:02:23.187          pages/index.e3591d2.js  2.01 KiB       1  [emitted] [immutable]         pages/index
14:02:23.187     pages/livestream.af3d4e7.js   235 KiB       2  [emitted] [immutable]         pages/livestream
14:02:23.187          pages/login.2da25e5.js  4.48 KiB       3  [emitted] [immutable]         pages/login
14:02:23.187              runtime.c326a79.js  2.39 KiB       4  [emitted] [immutable]         runtime
14:02:23.187   + 2 hidden assets
14:02:23.187  Entrypoint app [big] = runtime.c326a79.js app.ec921b7.js
14:02:23.187  WARNING in asset size limit: The following asset(s) exceed the recommended size limit (244 KiB).
14:02:23.187  This can impact web performance.
14:02:23.187  Assets: 
14:02:23.187    app.ec921b7.js (2.9 MiB)
14:02:23.187    5.4983c5e.js (283 KiB)
14:02:23.187  WARNING in entrypoint size limit: The following entrypoint(s) combined asset size exceeds the recommended limit (1000 KiB). This can impact web performance.
14:02:23.187  Entrypoints:
14:02:23.187    app (2.9 MiB)
14:02:23.187        runtime.c326a79.js
14:02:23.187        app.ec921b7.js
14:02:23.188  
14:02:23.188  Hash: 1f4bc8a097550a5414d8
14:02:23.188  Version: webpack 4.43.0
14:02:23.188  Time: 5851ms
14:02:23.188  Built at: 06/23/2020 5:02:23 PM
14:02:23.188                 Asset       Size  Chunks             Chunk Names
14:02:23.188                  4.js  236 bytes       4  [emitted]  
14:02:23.188        pages/index.js   7.14 KiB       1  [emitted]  pages/index
14:02:23.188   pages/livestream.js    704 KiB       2  [emitted]  pages/livestream
14:02:23.188        pages/login.js   20.8 KiB       3  [emitted]  pages/login
14:02:23.188             server.js   5.27 MiB       0  [emitted]  app
14:02:23.188  server.manifest.json  439 bytes          [emitted]  
14:02:23.188   + 5 hidden assets
14:02:23.188  Entrypoint app = server.js server.js.map
14:02:23.188  WARNING in ./node_modules_dev/component-classes/index.js
14:02:23.188  Module not found: Error: Can't resolve 'indexof' in '/vercel/30aec542/node_modules_dev/component-classes'
14:02:23.188   @ ./node_modules_dev/component-classes/index.js
14:02:23.188   @ ./node_modules_dev/ant-design-vue/lib/_util/css-animation/index.js
14:02:23.188   @ ./node_modules_dev/ant-design-vue/lib/_util/getTransitionProps.js
14:02:23.188   @ ./node_modules_dev/ant-design-vue/lib/alert/index.js
14:02:23.188   @ ./node_modules_dev/ant-design-vue/lib/index.js
14:02:23.188   @ ./plugins/antd-ui.js
14:02:23.188   @ ./.nuxt/index.js
14:02:23.188   @ ./.nuxt/server.js
14:02:23.188   @ multi ./node_modules_dev/@nuxt/components/lib/installComponents.js ./.nuxt/server.js
14:02:23.188  ℹ Ready to run nuxt start
14:02:23.718  ℹ Nuxt build took: 37141.950478 ms
14:02:23.718   ----------------- Install dependencies ----------------- 
14:02:23.720  Running npm install
14:02:34.813  > core-js@3.6.5 postinstall /vercel/30aec542/node_modules/@firebase/polyfill/node_modules/core-js
14:02:34.813  > node -e "try{require('./postinstall')}catch(e){}"
14:02:34.869  Thank you for using core-js ( https://github.com/zloirock/core-js ) for polyfilling JavaScript standard library!
14:02:34.869  The project needs your help! Please consider supporting of core-js on Open Collective or Patreon: 
14:02:34.869  > https://opencollective.com/core-js 
14:02:34.869  > https://www.patreon.com/zloirock 
14:02:34.869  Also, the author of core-js ( https://github.com/zloirock ) is looking for a good job -)
14:02:34.898  > core-js@3.6.5 postinstall /vercel/30aec542/node_modules/plyr/node_modules/core-js
14:02:34.898  > node -e "try{require('./postinstall')}catch(e){}"
14:02:34.954  Thank you for using core-js ( https://github.com/zloirock/core-js ) for polyfilling JavaScript standard library!
14:02:34.954  The project needs your help! Please consider supporting of core-js on Open Collective or Patreon: 
14:02:34.954  > https://opencollective.com/core-js 
14:02:34.954  > https://www.patreon.com/zloirock 
14:02:34.954  Also, the author of core-js ( https://github.com/zloirock ) is looking for a good job -)
14:02:34.958  > protobufjs@6.9.0 postinstall /vercel/30aec542/node_modules/protobufjs
14:02:34.958  > node scripts/postinstall
14:02:35.242  added 368 packages from 348 contributors and audited 368 packages in 11.124s
14:02:35.349  34 packages are looking for funding
14:02:35.349    run `npm fund` for details
14:02:35.349  found 0 vulnerabilities
14:02:35.369  ℹ Install dependencies took: 11650.396354 ms
14:02:35.369   ----------------- Collect artifacts ----------------- 
14:02:44.769  ℹ Collect artifacts took: 9395.286763 ms
14:02:45.005  Uploading build outputs...
14:02:48.319  Build completed. Populating build cache...
14:02:48.321   ----------------- Collect cache ----------------- 
14:02:48.325  ℹ 0 files collected from .now_cache
14:02:51.191  ℹ 46904 files collected from node_modules_dev
14:02:51.813  ℹ 10671 files collected from node_modules_prod
14:02:51.820  ℹ Collect cache took: 3498.353262 ms
14:03:08.001  Uploading build cache [67.34 MB]...
14:03:09.066  Build cache uploaded: 1064.256ms
14:03:09.083  Done with "nuxt.config.js"
alexkasongo commented 3 years ago

I'm still having this issue. Any update?

danielroe commented 3 years ago

@alexkasongo Check your Vercel logs for the cause and consider/try explanations above ☝️