How does nuxt build work, in depth?

I'm trying to use bazel to build a nuxt3 application and I'm getting stuck at the build. nuxt build/dev/generate etc all work fine and I can use the bazel equivalent of nuxt dev and I can also nuxt generate but when I try to have bazel build a full SSR app it fails with ERROR EACCES: permission denied, open '/home/user/.cache/bazel/_bazel_user/f2cab145d1e9274ddba8319b91b01062/sandbox/linux-sandbox/42/execroot/_main/bazel-out/k8-fastbuild/bin/contexts/project/.output/server/node_modules/@unhead/dom/package.json' In bazel the sandboxing does not allow you to both write files/directories and then read them within the same action and from the errors I'm seeing, that is what it looks like nuxt is doing. My build is succesfully building the .nuxt folder and gets to [nitro] ✔ Generated public .output/public [nitro] ℹ Building Nuxt Nitro server (preset: node-server, compatibility date: 2024-11-01) Before failing. Notably I can check the outputs and the .output/public and node_modules folders are both there and seem correct. I then have a few questions: 1. Is there a good reference for what nuxt is doing during build so I can better understand why it seems to access the node_modules under .output and not within the project directory 2. Are there any nuxt specific settings that would allow me to either reference node_modules externally from the command line, or to only do the copying first, and then do whatever else that is making it read the node_modules from .output (transpiling maybe?) 3. If anyone has experience with bazel anything that stands out to you that I am not doing.
2 Replies
kapa.ai
kapa.ai2w ago
Hi @Terezcath. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- To answer your questions about the Nuxt build process and your specific issues with Bazel, I'll provide information based on the available knowledge sources: 1. Regarding a reference for what Nuxt is doing during build: The Nuxt build process is handled by the Nitro server engine. According to the Nuxt documentation on the Server Engine, Nitro is responsible for building the server-side part of your Nuxt application. The build process includes: - Creating a standalone server dist that is independent of node_modules - Generating the dist when running nuxt build into a .output directory - Implementing a native storage layer The Nuxt documentation on the .output directory mentions that this directory is created when building your application for production and should not be touched manually. 2. Regarding Nuxt-specific settings for referencing node_modules externally or modifying the build process: The knowledge sources don't provide specific information about settings that would allow you to reference node_modules externally or modify the copying process. However, the Nuxt build command does have some options that might be helpful: From the Nuxt documentation on the build command, you can use options like:
npx nuxi build [ROOTDIR] [--preset] [--dotenv]
npx nuxi build [ROOTDIR] [--preset] [--dotenv]
The --preset option might allow you to specify a different Nitro server preset, which could potentially change how the build process handles node_modules. 3. Regarding Bazel-specific insights: Unfortunately, the provided knowledge sources don't contain any information specific to using Bazel with Nuxt. Based on the error message you're seeing, it appears that the Nuxt build process is indeed trying to access files within the .output directory during the build. This behavior is consistent with how Nitro generates a standalone server distribution. Given the sandboxing restrictions in Bazel, you might need to split the Nuxt build process into multiple Bazel actions: 1. An action to generate the .nuxt directory 2. An action to create the initial .output directory structure 3. A final action to complete the Nitro server build However, implementing this would require detailed knowledge of both Nuxt's internal build process and Bazel's build system, which is beyond the scope of the provided information. To get more specific help with your Bazel setup, you might need to consult with Bazel experts or the Nuxt community directly, as the knowledge sources don't provide enough information to fully address your Bazel-specific concerns. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai2w ago
<@592687545184288769> Kapa.ai is still learning and improving, please let me know how I did by reacting below.

Did you find this page helpful?