6

To deploy our nuxt website in ssr mode we first build and unit test website in the bitbucket pipeline and if tests are green we copy build files from bitbucket servers to our production server and trigger start.

The problem is that Nuxt documentation says nothing about which exact files are required on the server.

currently we are using:

.nuxt/  
server/  
static/  
nuxt.config.js 

Sometimes after adding functionality to the website, deployed version throws an error:

Error: Server resources are not available!

At the same time local version works fine.
Also running production server locally on the project works. Error kinda hints that some paths picked up incorrectly by nuxt.. but the directory structure is completely the same.

Any ideas why this happens and how to fix that?

31415926
  • 3,811
  • 7
  • 47
  • 78
  • Have you tried deploying the entire repository to the production server and seeing if the issue persists? – Ohgodwhy Feb 01 '19 at 19:11
  • You use SSR mode. Did you try deploy your app as static files via `nuxt generate`? – Lev Khruschev Feb 01 '19 at 19:32
  • we tried to build on server. then it works. that's why we thought that maybe during the build nuxt assigns absolute paths or something. – 31415926 Feb 01 '19 at 19:33
  • we need ssr mode as we have dynamic routing.. I'm pretty sure static files will work – 31415926 Feb 01 '19 at 19:35
  • Did you clean old .nuxt folder before new deployment? Did u copy node modules to server? – Aldarund Feb 02 '19 at 03:38
  • @Aldarund, yes! its always clean copy. No, I do install node_modules before every run... copying node_modules is not a fast procedure.. – 31415926 Feb 02 '19 at 10:32
  • That should be fine. Is it happening every time ? Can you reproduce it reliable ? – Aldarund Feb 02 '19 at 12:01
  • @Aldarund, it can be reproduced. I was even able to reproduce it on my pc by building the project and copying specified files to separate directory and starting server locally. It's code specific. Last time I was introducing nuxtServerInit in store/index.js but after dancing around for 1 hour I found a way so it doesn't brake. But its not fun anyway as it brakes only when deployed... Before that It was braking the same way when I was introducing conditional load of styles during the build.. but again by dancing around the problem was solved and I still don't know what causing this.. – 31415926 Feb 02 '19 at 13:10
  • Create a reproduction repo please with steps to reproduce. – Aldarund Feb 02 '19 at 14:30

2 Answers2

3

If errors also mentions, Please check "file path"/.nuxt/dist/server existence. Then on the terminal

cd .nuxt

check if 'dist' folder exists. If it does not exists,

go back and npm run build. this will generate the 'dist' folder for use.

If Still facing the issue, try,

npm install --save nuxt
npm install --save vue-server-renderer
lokanath
  • 237
  • 6
  • 16
2

Try adding: dev: process.env.NODE_ENV === 'DEV' to nuxt.config.js