Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting _import_meta_url_ is not defined error for a Nuxt 3.10.3 and nuxt content project deployed to AWS Lambda #26170

Open
anjali89r opened this issue Mar 10, 2024 · 4 comments

Comments

@anjali89r
Copy link

Environment

  • Operating System: Darwin
  • Node Version: v20.11.0
  • Nuxt Version: 3.10.3
  • CLI Version: 3.10.1
  • Nitro Version: 2.9.2
  • Package Manager: npm@10.2.4
  • Builder: -
  • User Config: devtools, modules, content, nitro
  • Runtime Modules: @nuxt/content@2.12.1
  • Build Modules: -

Reproduction

https://stackblitz.com/edit/github-agpzne-qkcpqs?file=pages%2F%5B...slug%5D.vue

Describe the bug

My project is a SSR application deployed to AWS Lambda. I'm adding a blog section to this app and used Nuxt Content in the document-driven mode. After adding the nuxt content to this project, when I deploy the application, I'm getting an internal server error and below is the error stack in the AWS Cloudwatch,
image

2024-03-10T04:04:37.099Z undefined ERROR Uncaught Exception { "errorType": "ReferenceError", "errorMessage": "_import_meta_url_ is not defined", "stack": [ "ReferenceError: _import_meta_url_ is not defined", " at file:///var/task/index.mjs:1:65", " at ModuleJob.run (node:internal/modules/esm/module_job:218:25)", " at async ModuleLoader.import (node:internal/modules/esm/loader:329:24)", " at async _tryAwaitImport (file:///var/runtime/index.mjs:1008:16)", " at async _tryRequire (file:///var/runtime/index.mjs:1057:86)", " at async _loadUserApp (file:///var/runtime/index.mjs:1081:16)", " at async UserFunction.js.module.exports.load (file:///var/runtime/index.mjs:1119:21)", " at async start (file:///var/runtime/index.mjs:1282:23)", " at async file:///var/runtime/index.mjs:1288:1" ] }
When I remove the nuxt content from the project, it works as expected. Also when I tried the nitro preset to the default node server, it worked fine.

Additional context

Nuxt.config.ts,

// https://nuxt.com/docs/api/configuration/nuxt-config
export default defineNuxtConfig({
  devtools: { enabled: true },
  modules: ['@nuxt/content'],
  content: {
    documentDriven: true,
  },
  nitro: {
    preset: 'aws-lambda',
    inlineDynamicImports: true,
  },
});

Nuxt build command for Deployment,

NUXT_PUBLIC_API_BASE=https://my-api.com NUXT_APP_CDN_URL=my-static-bucket-url npx nuxt build

Logs

No response

Copy link

stackblitz bot commented Mar 10, 2024

Fix this issue in StackBlitz Codeflow Start a new pull request in StackBlitz Codeflow.

@danielroe
Copy link
Member

This is likely an upstream issue with Nitro.

cc: @pi0

@cfvargashz
Copy link

@anjali89r Disabling inlineDynamicimports within nuxt.config.js > nitro (inlineDynamicImports: false) works for me

@anjali89r
Copy link
Author

@cfvargashz thanks for that. yes it works after disabling the inline dynamic imports

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants