Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/presets/aws-amplify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export default definePreset({
}
})

try {
/* try {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing the explicit sqlite3 module check creates a silent failure path for AWS Amplify builds that don't have Node.js 22.5+ or don't have better-sqlite3 installed. This could cause builds to hang on interactive prompts during CI/CD.

View Details
πŸ“ Patch Details
diff --git a/src/presets/aws-amplify.ts b/src/presets/aws-amplify.ts
index ef66032b..6445ceb1 100644
--- a/src/presets/aws-amplify.ts
+++ b/src/presets/aws-amplify.ts
@@ -1,5 +1,6 @@
 import { definePreset } from '../utils/preset'
 import { logger } from '../utils/dev'
+import { isNodeSqliteAvailable } from '../utils/dependencies'
 import nodePreset from './node'
 
 export default definePreset({
@@ -16,16 +17,23 @@ export default definePreset({
       }
     })
 
-    /* try {
-      await import('sqlite3')
-
-      options.experimental ||= {}
-      options.experimental.sqliteConnector = 'sqlite3'
+    // Ensure explicit SQLite connector to avoid interactive prompts in CI/CD
+    options.experimental ||= {}
+    
+    if (isNodeSqliteAvailable()) {
+      // Use native Node.js SQLite for Node.js 22.5+
+      options.experimental.sqliteConnector = 'native'
+    } else {
+      // For older Node.js versions, verify sqlite3 is available
+      try {
+        await import('sqlite3')
+        options.experimental.sqliteConnector = 'sqlite3'
+      }
+      catch {
+        logger.error('Nuxt Content requires `sqlite3` module to work in AWS Amplify environment with Node.js < 22.5. Please run `npm install sqlite3` to install it and try again.')
+        process.exit(1)
+      }
     }
-    catch {
-      logger.error('Nuxt Content requires `sqlite3` module to work in AWS Amplify environment. Please run `npm install sqlite3` to install it and try again.')
-      process.exit(1)
-    } */
   },
   async setupNitro(nitroConfig) {
     const database = nitroConfig.runtimeConfig?.content?.database

Analysis

AWS Amplify preset causes interactive prompts in CI/CD when better-sqlite3 is missing

What fails: AWS Amplify preset with commented sqlite3 check falls back to ensurePackageInstalled('better-sqlite3') which calls logger.prompt() in CI/CD environments, causing builds to hang with "TTY initialization failed" error.

How to reproduce:

# In AWS Amplify environment with Node.js < 22.5 and missing better-sqlite3:
# 1. Use @nuxt/content with aws-amplify preset
# 2. Don't install better-sqlite3 dependency
# 3. Build in CI/CD environment (non-interactive)

Result: Build hangs waiting for user input on package installation prompt, then fails with TTY error.

Expected: Fast failure with clear AWS Amplify-specific error message, like the original commented code provided.

Root cause: findBestSqliteAdapter() fallback calls ensurePackageInstalled() which uses interactive prompts unsuitable for CI/CD environments when no explicit sqliteConnector is set.

await import('sqlite3')

options.experimental ||= {}
Expand All @@ -25,7 +25,7 @@ export default definePreset({
catch {
logger.error('Nuxt Content requires `sqlite3` module to work in AWS Amplify environment. Please run `npm install sqlite3` to install it and try again.')
process.exit(1)
}
} */
},
async setupNitro(nitroConfig) {
const database = nitroConfig.runtimeConfig?.content?.database
Expand Down
Loading