Closed yongjie-zhang-mail closed 7 months ago
Can't repro this in latest nuxt + nitro. See the StackBlitz
I just experienced exactly the same issue. Joi works perfectly with dev server but doesn't with build. Just throws same error as above. I tried with:
Operating System: Windows_NT Node Version: v20.11.1 Nuxt Version: 3.10.2 CLI Version: 3.10.1 Nitro Version: 2.8.1 Package Manager: npm@10.2.4 Builder: -
User Config: app, runtimeConfig, css, modules, quasar, pinia, imports, vite, content, vue, nitro, devtools, devServer, ssr Runtime Modules: nuxt-quasar-ui@2.0.7, @pinia/nuxt@0.5.1, @vueuse/nuxt@10.7.2, @pinia-plugin-persistedstate/nuxt@1.2.0, @nuxt/content@2.12.0, @formkit/auto-animate/nuxt@0.8.1 Build Modules: -
Joi: 17.12.1
wonder if there's any proper solution for that problem?
I just experienced exactly the same issue. Joi works perfectly with dev server but doesn't with build. Just throws same error as above. I tried with:
Operating System: Windows_NT Node Version: v20.11.1 Nuxt Version: 3.10.2 CLI Version: 3.10.1 Nitro Version: 2.8.1 Package Manager: npm@10.2.4 Builder: -
User Config: app, runtimeConfig, css, modules, quasar, pinia, imports, vite, content, vue, nitro, devtools, devServer, ssr Runtime Modules: nuxt-quasar-ui@2.0.7, @pinia/nuxt@0.5.1, @vueuse/nuxt@10.7.2, @pinia-plugin-persistedstate/nuxt@1.2.0, @nuxt/content@2.12.0, @formkit/auto-animate/nuxt@0.8.1 Build Modules: -
Joi: 17.12.1
wonder if there's any proper solution for that problem?
never mind ;) I found this solution and it seems to work perfectly: https://github.com/nuxt/nuxt/discussions/23065#discussioncomment-6939569
In my project, I'm using Nuxt 3.7.4 and Joi 17.11.0 for parameter validation. Everything works fine in development mode, but when I build the project and run it in a Node.js environment, I encounter the following error:
Reproducible Steps:
In a Node.js environment with version 18.15.0, I created a Nuxt 3 project using the command
npx nuxi init <project_name>
and added the Joi dependency withyarn add joi
.I added a file
server\api\user[id].get.ts
with the following content:I ran
yarn run dev
and sent a request tohttp://localhost:3000/api/user/123
, which resulted in the following correct response:I then executed
yarn run build
andnode .output/server/index.mjs
and attempted to send a request tohttp://localhost:3000/api/user/123
, but received the following error:Key Code Snippets:
package.json
Actual Result: I encounter the aforementioned error and cannot run the built project as expected.