Additional Details
Create app via yarn create nuxt-app app-name. Choose typescript, axios, jest.
Install following depedencies:
Install following dev depedencies:
Run command nuxt-ts build and wait until build ends. Check if everything works corretly by running nuxt-ts start
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.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
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
Most helpful comment
@kevcodez it should be nuxt-ts and it is fixed in CNA https://github.com/nuxt/create-nuxt-app/pull/568