Nuxt Serverless with the Nuxt Content Documentation Theme - Cannot use import statement outside a module
robmellett opened this issue · comments
Hey @wan2land,
I just wanted to thank you for this amazing plugin, it has so much potential within the Nuxt ecosystem.
I was wondering if you could point me in the right direction.
I'm using your plugin, and trying to deploy the next default Nuxt Content Theme to serverless.
// `nuxt.config.js`
import theme from '@nuxt/content-theme-docs'
module.exports = theme({
target: 'server',
docs: {
primaryColor: '#E24F55'
},
loading: { color: '#00CD81' },
telemetry: false,
build: {
// You can extend webpack config here
transpile: ['@nuxt/content-theme-docs'],
},
})
When running serverless deploy
, I'm seeing the following error.
Serverless: Running "serverless" installed locally (in service node_modules)
Serverless: Deprecation warning: Resolution of lambda version hashes was improved with better algorithm, which will be used in next major release.
Switch to it now by setting "provider.lambdaHashingVersion" to "20201221"
More Info: https://www.serverless.com/framework/docs/deprecations/#LAMBDA_HASHING_VERSION_V2
Serverless Nuxt Plugin: build nuxt
Syntax Error --------------------------------------------
/github/workspace/nuxt.config.js:1
import theme from '@nuxt/content-theme-docs'
^^^^^^
SyntaxError: Cannot use import statement outside a module
at compileFunction (<anonymous>)
at wrapSafe (internal/modules/cjs/loader.js:979:16)
at Module._compile (internal/modules/cjs/loader.js:1027:27)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
at Module.load (internal/modules/cjs/loader.js:928:32)
at Function.Module._load (internal/modules/cjs/loader.js:769:14)
at Module.require (internal/modules/cjs/loader.js:952:19)
at require (internal/modules/cjs/helpers.js:88:18)
at ServerlessNuxtPlugin.build (/github/workspace/node_modules/serverless-nuxt-plugin/src/index.js:69:22)
at PluginManager.invoke (/github/workspace/node_modules/serverless/lib/classes/PluginManager.js:552:20)
at async PluginManager.spawn (/github/workspace/node_modules/serverless/lib/classes/PluginManager.js:574:5)
at async Object.before:deploy:deploy [as hook] (/github/workspace/node_modules/serverless/lib/plugins/deploy.js:49:11)
at async PluginManager.invoke (/github/workspace/node_modules/serverless/lib/classes/PluginManager.js:552:9)
at async PluginManager.run (/github/workspace/node_modules/serverless/lib/classes/PluginManager.js:598:7)
at async Serverless.run (/github/workspace/node_modules/serverless/lib/Serverless.js:313:5)
at async /usr/local/lib/node_modules/serverless/scripts/serverless.js:634:9
For debugging logs, run again after setting the "SLS_DEBUG=*" environment variable.
Get Support --------------------------------------------
Docs: docs.serverless.com
Bugs: github.com/serverless/serverless/issues
Issues: forum.serverless.com
Your Environment Information ---------------------------
Operating System: linux
Node Version: 14.16.1
Framework Version: 2.38.0 (local)
Plugin Version: 4.5.3
SDK Version: 4.2.2
Components Version: 3.9.1
I was wondering if you had any ideas on how I might approach this error? Would it be possible to use some type of trickery using require
.
Any advice or suggestions would be much appreciated. I've put together a issue repo here.
https://github.com/robmellett/nuxt-documentation-serverless
In serverless-nuxt, the config file is used without building it with webpack.
nuxt.config.js
const theme = require('@nuxt/content-theme-docs')
/* .. */