Nuxt.js: After pulling new changes "nuxt-ts build" command works only after rebooting server.

Created on 2 Jul 2020  路  4Comments  路  Source: nuxt/nuxt.js

Versions

  • nuxt: 2.13.2
  • node: 10.18.1

Reproduction


Additional Details



Steps to reproduce

Create app via yarn create nuxt-app app-name. Choose typescript, axios, jest.
Install following depedencies:

  • @nuxtjs/google-analytics
  • nuxt-i18n

Install following dev depedencies:

  • sass-loader
  • node-sass

Run command nuxt-ts build and wait until build ends. Check if everything works corretly by running nuxt-ts start

What is Expected?

  • Correct build of client and server side ( works on my pc )

What is actually happening?

  • nuxt-ts build command builds only client side and then ends build before starting server side by just throwing Done ... s. No errors are shown in console.

Why am I reporting?

  • This issue happend to me evertime I pull new changes and try to build them. When it happend first time I just rebooted the server and it worked. So why is it a problem? On this server are also other websites and rebooting it casues their downtime, its just annoying thing to do everytime I want to pull new changes. I tried renaming nuxt.config.js to nuxt.config.ts and again everything works perfectly on my pc but on server I have to reboot it so it can build correctly. I have no clue what is a casue of this but I'm happy to help to fix this issue so maybe other people won't have this problem.

I almost forgot one more thing. Before when dev command was nuxt dev after building app on my pc I couldn't run even nuxt because of Unexpected token export error. I've changed nuxt to nuxt-ts and it works right now properly.

This issue might somhow refer to this issue: https://github.com/nuxt/nuxt.js/issues/7643

bug-report

Most helpful comment

@kevcodez it should be nuxt-ts and it is fixed in CNA https://github.com/nuxt/create-nuxt-app/pull/568

All 4 comments

Ok, I worked a bit around this and seems that running app with pm2 is the problem here. Somehow when I use pm2 start yarn --name "app-name" -- start and then try to build, it doesn't work as I described before. I have also few other apps using nuxt (version: 2.10.2) on this server with javascript and I never had any problem trying to build them while they are running.

@SerekKiri When it works locally but not on external server, it's often because of environment variables or the tools used to restart web server.

In your case it might be wrong pm2 setup.

Furthermore, Building an app while it's running can lead you to broken app, this it not how you should do things.
You're supposed to build the new version aside then replace the old one(s) by the new one(s).

Running into the same issue on Windows with latest version of yarn (1.x) and nuxt. After running yarn build && yarn export, yarn dev is broken with the error "Unexpected token export".

I also generated the project using npx (with typescript option enabled). I now changed the dev script from "nuxt" to "nuxt-ts dev" - this seems to fix the issue. Shouldn't the dev command be nuxt-ts rather than nuxt?

@kevcodez it should be nuxt-ts and it is fixed in CNA https://github.com/nuxt/create-nuxt-app/pull/568

Was this page helpful?
0 / 5 - 0 ratings

Related issues

uptownhr picture uptownhr  路  3Comments

nassimbenkirane picture nassimbenkirane  路  3Comments

surmon-china picture surmon-china  路  3Comments

o-alexandrov picture o-alexandrov  路  3Comments

maicong picture maicong  路  3Comments