Я пытаюсь развернуть приложение nuxt js в windows IIS с помощью модуля IISNODE. но я не могу заставить его работать.
Я создал сервер. js файл в root репо со следующим кодом:
const express = require('express')
const {Nuxt} = require('nuxt')
const app = express()
const host = process.env.HOST || '127.0.0.1'
const port = process.env.PORT || 3000
// Import and set Nuxt.js options
let config = require('./nuxt.config.js')
const nuxt = new Nuxt(config)
// Give Nuxt middleware to express
app.use(nuxt.render)
// Listen the server
app.listen(port, host);
console.log('Server listening on ' + host + ':' + port);
Затем я настроил файл web.config в IIS со следующим кодом:
<!-- indicates that the hello.js file is a node.js application
to be handled by the iisnode module -->
<handlers>
<add name="iisnode" path="app/server.js" verb="*" modules="iisnode" />
</handlers>
<rewrite>
<rules>
<rule name="myapp">
<match url="/*" />
<action type="Rewrite" url="app/server.js" />
</rule>
</rules>
</rewrite>
При попытке запустить приложение я получаю следующую ошибку в IISNode.
Application has thrown an uncaught exception and is terminated:
C:\inetpub\Web\frontend\app\nuxt.config.js:2
export default {
^^^^^^
SyntaxError: Unexpected token 'export'
at new Script (vm.js:88:7)
at createScript (vm.js:263:10)
at Object.runInThisContext (vm.js:311:10)
at wrapSafe (internal/modules/cjs/loader.js:1057:15)
at Module._compile (internal/modules/cjs/loader.js:1120:27)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1176:10)
at Module.load (internal/modules/cjs/loader.js:1000:32)
at Function.Module._load (internal/modules/cjs/loader.js:899:14)
at Module.require (internal/modules/cjs/loader.js:1042:19)
at require (internal/modules/cjs/helpers.js:77:18)
Кажется, он не принимает экспорт в файл nuxt.config. js.
Вот мой nuxt.config. js
export default {
mode: 'universal',
server: {
port: 2001, // default: 3000
host: '0.0.0.0' // default: localhost
},
/*
** Headers of the page
*/
head: {
title: process.env.npm_package_name || '',
meta: [
{ charset: 'utf-8' },
{ name: 'viewport', content: 'width=device-width, initial-scale=1' },
{ hid: 'description', name: 'description', content: process.env.npm_package_description || '' }
],
link: [
{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }
],
script: [
{}
]
},
/*
** Customize the progress-bar color
*/
loading: { color: '#fff' },
/*
** Global CSS
*/
css: [
],
/*
** Plugins to load before mounting the App
*/
plugins: [
],
/*
** Nuxt.js dev-modules
*/
buildModules: [
],
/*
** Nuxt.js modules
*/
modules: [
// Doc: https://bootstrap-vue.js.org
'bootstrap-vue/nuxt',
'@nuxtjs/axios',
'@nuxtjs/toast',
'@nuxtjs/auth'
],
/*
** Build configuration
*/
build: {
/*
** You can extend webpack config here
*/
extend(config, ctx) {
}
},
toast: {
position: 'top-center',
duration: 1500,
singleton: false,
register: [ // Register custom toasts
{
name: 'my-error',
message: 'Oops...Something went wrong',
options: {
type: 'error'
}
}
]
},
axios: {
baseURL: 'http://backend.local/'
},
auth: {
strategies: {
local: {
endpoints: {
login: { url: 'users/authenticate', method: 'post', propertyName: 'token' },
user: { url: 'user', method: 'get', propertyName: 'authorizedData.user' },
logout: false
}
}
}
}
}
любая помощь в решении этой проблемы будет принята с благодарностью.
Спасибо
CES