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

SST & Next.js 14 Error Cannot find module '@libsql/linux-arm64-gnu' #186

Closed
nadjitanMabuhayTech opened this issue Mar 5, 2024 · 2 comments

Comments

@nadjitanMabuhayTech
Copy link

When I deploy a Next.js 14 app using SST I get this error:

Error: Cannot find module '@libsql/linux-arm64-gnu'
Require stack:
- /var/task/node_modules/libsql/index.js
- /var/task/node_modules/@libsql/client/lib-cjs/sqlite3.js
- /var/task/node_modules/@libsql/client/lib-cjs/node.js
- /var/task/.next/server/app/[locale]/(app-pages)/genai/page.js
- /var/task/node_modules/next/dist/server/require.js
- /var/task/node_modules/next/dist/server/next-server.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:1134:15)
    at /var/task/node_modules/next/dist/server/require-hook.js:55:36
    at Module._load (node:internal/modules/cjs/loader:975:27)
    at Module.require (node:internal/modules/cjs/loader:1225:19)
    at mod.require (/var/task/node_modules/next/dist/server/require-hook.js:65:28)
    at require (node:internal/modules/helpers:177:18)
    at Object.<anonymous> (/var/task/node_modules/libsql/index.js:42:5)
    at Module._compile (node:internal/modules/cjs/loader:1356:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1414:10)
    at Module.load (node:internal/modules/cjs/loader:1197:32) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/var/task/node_modules/libsql/index.js',
    '/var/task/node_modules/@libsql/client/lib-cjs/sqlite3.js',
    '/var/task/node_modules/@libsql/client/lib-cjs/node.js',
    '/var/task/.next/server/app/[locale]/(app-pages)/genai/page.js',
    '/var/task/node_modules/next/dist/server/require.js',
    '/var/task/node_modules/next/dist/server/next-server.js'
  ]
}

Am I supposed to include it in package.json?

@nadjitanMabuhayTech
Copy link
Author

I update my sst.config.ts and my deployment now works. The problem was that I needed to change my Lambda architecture and update the nodejs because previously it was using the default 18.x.

const site = new NextjsSite(stack, "site", {
  permissions: [bucket],
  bind: [bucket],
  cdk: { server: { architecture: Architecture.X86_64 } },
  runtime: "nodejs20.x"
})

@bxrne
Copy link

bxrne commented Mar 18, 2024

@nadjitanMabuhayTech I am having the same problem and have the same stack. After adding your cdk options I get the same error (it cannot find the x86 pkg when on x86 and the same for amd64 when on it). I think it might be a version issue?

Below is my package.json and a link to the repo if you have any ideas:

{
	"name": "soar",
	"description": "Aviation prototyping and experimentation platform for hobbyists",
	"version": "1.0.0",
	"private": true,
	"scripts": {
		"dev": "sst bind next dev",
		"build": "next build",
		"start": "next start",
		"lint": "next lint",
		"db:generate": "drizzle-kit generate:sqlite",
		"db:migrate": "tsx src/lib/db/migrate.ts",
		"db:drop": "drizzle-kit drop",
		"db:pull": "drizzle-kit introspect:sqlite",
		"db:push": "drizzle-kit push:sqlite",
		"db:studio": "drizzle-kit studio",
		"db:check": "drizzle-kit check:sqlite"
	},
	"dependencies": {
		"@libsql/client": "^0.3.0",
		"@lucia-auth/adapter-sqlite": "^2.0.1",
		"@radix-ui/react-avatar": "^1.0.4",
		"@radix-ui/react-dropdown-menu": "^2.0.6",
		"@radix-ui/react-label": "^2.0.2",
		"@radix-ui/react-slot": "^1.0.2",
		"@t3-oss/env-nextjs": "^0.9.2",
		"class-variance-authority": "^0.7.0",
		"clsx": "^2.1.0",
		"drizzle-orm": "^0.30.2",
		"drizzle-zod": "^0.5.1",
		"lucia": "^2.7.7",
		"lucide-react": "^0.358.0",
		"nanoid": "^5.0.6",
		"next": "14.1.3",
		"next-themes": "^0.3.0",
		"react": "^18",
		"react-dom": "^18",
		"sonner": "^1.4.3",
		"tailwind-merge": "^2.2.2",
		"tailwindcss-animate": "^1.0.7",
		"zod": "^3.22.4",
		"@aws-sdk/s3-request-presigner": "^3.533.0",
		"@hookform/resolvers": "^3.3.4",
		"@radix-ui/react-dialog": "^1.0.5",
		"@radix-ui/react-popover": "^1.0.7",
		"@radix-ui/react-select": "^2.0.0",
		"@tanstack/react-query": "^4.32.6",
		"@trpc/client": "^10.37.1",
		"@trpc/next": "^10.37.1",
		"@trpc/react-query": "^10.37.1",
		"@trpc/server": "^10.37.1",
		"date-fns": "^3.3.1",
		"libsql": "^0.3.10",
		"react-day-picker": "^8.10.0",
		"react-hook-form": "^7.50.1",
		"resend": "^3.1.0",
		"server-only": "^0.0.1",
		"sharp": "^0.33.2",
		"superjson": "^2.2.1"
	},
	"devDependencies": {
		"@tsconfig/node18": "^18.2.1",
		"@types/node": "^20",
		"@types/react": "^18",
		"@types/react-dom": "^18",
		"autoprefixer": "^10.0.1",
		"aws-cdk-lib": "2.132.1",
		"constructs": "10.3.0",
		"dotenv": "^16.4.5",
		"drizzle-kit": "^0.20.14",
		"eslint": "^8",
		"eslint-config-next": "14.1.3",
		"postcss": "^8",
		"sst": "^2.41.2",
		"tailwindcss": "^3.3.0",
		"tsx": "^4.7.1",
		"typescript": "^5"
	}
}

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

No branches or pull requests

2 participants