Nuxt-Express Deploying to Azure Issue

939 views Asked by At

I am trying to get a nuxt with express web app deployed to an Azure Web App running Node. Here's what I have done so far:

  1. Created a build using VSTS
  2. Deployed build to Azure Web App using VSTS release (using MS's Azure App Service Deploy task)
  3. I also made a few changes per a couple closed issues:
    • Changed scripts to use fully qualified paths like "node ./node_modules/nuxt/bin/nuxt start" based on response in this issue
    • Created a stub server.js per response in this issue but I did have to make a change to the call to nuxt.Server to be nuxt.listen(port, host) instead.
  4. Enabled logging to the iisnode log folder based on this iisnode.yml file used in azure
  5. Here is the log information being returned now that makes me think it is still a configuration issue:

    Sat Aug 26 2017 16:12:45 GMT+0000 (Coordinated Universal Time): Application has thrown an uncaught exception and is terminated:
    SyntaxError: Unexpected token {
        at Module._compile (module.js:434:25)
        at Object..js (module.js:464:10)
        at Module.load (module.js:353:31)
        at Function._load (module.js:311:12)
        at Module.require (module.js:359:17)
        at require (module.js:375:17)
        at Object.<anonymous> (D:\Program Files\iisnode\interceptor.js:459:1)
        at Module._compile (module.js:446:26)
        at Object..js (module.js:464:10)
        at Module.load (module.js:353:31) 
    

Here are the contents of the server.js file I created based on the notes in 3:

const fs = require('fs');
const { Nuxt } = require('nuxt');
const resolve = require('path').resolve;  

const rootDir = resolve('.');
const nuxtConfigFile = resolve(rootDir, 'nuxt.config.js');  

let options = {};
if (fs.existsSync(nuxtConfigFile)) {
  options = require(nuxtConfigFile);
}
if (typeof options.rootDir !== 'string') {
  options.rootDir = rootDir;
}
options.dev = false; // Force production mode (no webpack middleware called)  

const nuxt = new Nuxt(options);  

const port = process.env.PORT;
const host = process.env.HOST;  

nuxt.listen(port, host);  

If need be I can give you the web.config and iisnode.yml files if those would be helpful when looking at the config of the azure web app.


Also I have posted this as an issue in the nuxt.js github repo if you would rather answer this question over there

0

There are 0 answers