I have nuxt3js project (version: v3.0.0-rc.3). For additional server-side features like WebSocket server; Authentication Checks; Database connection; ..., I have created a modules folder with all this additional logic.
📦project
┣ 📂modules
┃ ┣ 📂auth
┃ ┃ ┣ 📜index.ts
┃ ┃ ┗ 📜...
┃ ┗ 📂websocket
┃ ┃ ┗ 📜index.ts
┃ ┗ 📂...
┃ ┗ 📜...
┣ ...
┣ 📜nuxt.config.ts
┃
┗ ...
Then in nuxt.config.ts I have added them like so:
// nuxt.config.ts
import { defineNuxtConfig } from "nuxt";
export default defineNuxtConfig({
...
modules: [
...
"~/modules/auth/index.ts",
"~/modules/websocket/index.ts",
...
],
...
});
Project logic works fine while developing, and starting everything with yarn dev
, before everything starts all modules are executed one by one as excpected. Now when the time has come to the point when the project is ready for its first deployment I am running yarn build
which finishes with no errors and produces following folder:
📦.output
┣ 📂public
┃ ┗ 📂_nuxt
┃ ┃ ┗ 📜...
┣ 📂server
┃ ┣ 📂chunks
┃ ┃ ┗ 📜...
┃ ┣ 📂node_modules
┃ ┃ ┗ 📂...
┃ ┃ ┗ 📜...
┃ ┣ 📜index.mjs
┃ ┣ 📜index.mjs.map
┃ ┗ 📜package.json
┗ 📜nitro.json
Now starting the server with hinted command node.output/server/index.mjs
successfully starts a server that is accessible from the browser, the only problem is that none of my modules logic is working, it seems as yarn build
does not include my modules to the end build.
What I am missing?
Maybe please check if any code / package needs to be added in the nuxt.config.js transpile section. eg headless ui & @aspida/axios needs to be added
build: {
transpile: ['@headlessui/vue', '@aspida/axios'],
}
Read more: https://v3.nuxtjs.org/guide/going-further/esm/#transpiling-libraries
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.