nitrojs / nitro

Next Generation Server Toolkit. Create web servers with everything you need and deploy them wherever you prefer.
https://nitro.build
MIT License
6.28k stars 517 forks source link

Cannot find package knex on production build of nuxt server (api routes) #1496

Open issue-up[bot] opened 1 year ago

issue-up[bot] commented 1 year ago
   Forwarded from downstream issue: - https://github.com/nuxt/nuxt/issues/22373 by @bvqbao

### Environment ------------------------------ - Operating System: Windows_NT - Node Version: v18.16.0 - Nuxt Version: 3.6.5 - Nitro Version: 2.5.2 - Package Manager: npm@9.5.1 - Builder: vite - User Config: devtools, modules, content, experimental - Runtime Modules: @nuxtjs/tailwindcss@6.8.0, @nuxt/content@2.7.2, @nuxtjs/eslint-module@4.1.0 - Build Modules: - ------------------------------ ### Reproduction https://github.com/bvqbao/nuxt3-module-notfound ### Describe the bug I have created some API in ~/server/api. The API use knex package to access to an SQLite DB. In dev mode (```npm run dev```), the API work as expected: image However, when I build the server for production (```npm run build```) and run the server (```npm run preview```), the server returns an error about "Cannot find package ..." knex, altho it is present in ```./output/server/node_modules```: image I don't use TypeScript but JavaScript in ~/server. ### Additional context _No response_ ### Logs _No response_
Zebnastien commented 3 months ago

Hi, same problem here (I do use TypeScript in ~/server). Nuxt server project with knex fails in preview/production mode.

Operating System: Windows_NT Node Version: v22.6.0 Nuxt Version: 3.12.4 Nitro Version: 2.9.7 Package Manager: bun@1.1.24 Builder: vite User Config: devtools, compatibilityVersion : 4 Runtime Modules: - Build Modules: -

Predprinimatel89 commented 3 weeks ago

Уже больше года проблема не сортируется. Nitro мы помираем?