Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

278
Views
¿Puedo usar Knex.js con Next.js?

Estoy tratando de usar Knex.js con mi aplicación Next.js, ya que Knex.js es el único generador de consultas SQL que conozco muy bien y me siento más cómodo para desarrollar. Sin embargo, no puedo encontrar una manera de integrar Knex.js con mi aplicación. Aquí está el código fuente:

 import knex from 'knex'; const connection = knex({ client: 'mysql', connection: process.env.DATABASE_URL, asyncStackTraces: true, debug: true }); export default connection;

Y cada vez que trato de usarlo en mi página de índice, que se ve así:

 import Head from 'next/head'; import Container from 'react-bootstrap/Container'; import Col from 'react-bootstrap/Col'; import Row from 'react-bootstrap/Row'; import Navbar from '../components/Navbar'; import con from '../database/connection'; export async function getServerSideProperties(context) { const result = await con('test').select(); return { props: { test: result } } } export default function Home({ test }) { return ( <> <Head> <title>Create Next App</title> <meta name="description" content="Generated by create next app" /> <link rel="icon" href="/favicon.ico" /> </Head> <Navbar /> <Container className="text-center"> <Row> <Col> {test} </Col> </Row> </Container> </> ) }

Recibo este error:

 error - ./node_modules/knex/lib/migrations/util/fs.js:1:0 Module not found: Can't resolve 'fs' Did you mean './fs'? Requests that should resolve in the current directory need to start with './'. Requests that start with a name are treated as module requests and resolve within module directories (node_modules). If changing the source code is not an option there is also a resolve options called 'preferRelative' which tries to resolve these kind of requests in the current directory too. Import trace for requested module: ./node_modules/knex/lib/migrations/seed/Seeder.js ./node_modules/knex/lib/knex-builder/make-knex.js ./node_modules/knex/lib/knex-builder/Knex.js ./node_modules/knex/lib/index.js ./node_modules/knex/knex.js ./src/database/connection.js ./src/pages/index.js https://nextjs.org/docs/messages/module-not-found Could not find files for / in .next/build-manifest.json Could not find files for / in .next/build-manifest.json

¿Es posible integrar Knex.js a Next.js? Si no es así, ¿cuáles son las alternativas?

about 4 years ago · Santiago Gelvez
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!