N
Nuxtβ€’2w ago
Shay Rosenfeld

Build does not create index.mjs

Hi. I am having a strange problem. Made some changes (added nuxt scripts) to my SSR, but now after building using npm run build, the file .output/server/index.mjs is not being created, which leads to failure on pm2 side. This is the first time this happening with this app and it's super strange. Versions: Nuxt 3.13.2 with Nitro 2.9.7. Relevant files of nuxt.config.tx, ecosystem.config.cjs and package.json can be found here (was too long for the message): https://pastebin.com/acsTNTNy Any help would be super appreciated πŸ™‚
Pastebin
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
2 Replies
kapa.ai
kapa.aiβ€’2w ago
Hi @Shay Rosenfeld. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- Based on the information provided in the knowledge sources, it appears that you're encountering an issue where the .output/server/index.mjs file is not being generated during the build process. This file is crucial for running your Nuxt application in production, especially when using PM2 as your process manager. Let's explore some potential causes and solutions: 1. Build Process: Ensure that your build process is completing successfully without any errors. The Nuxt deployment documentation (https://nuxt.com/docs/getting-started/deployment) mentions that running nuxt build should generate the necessary files in the .output directory, including the server/index.mjs file. 2. Node.js Version: Make sure you're using a compatible Node.js version. Nuxt 3 requires Node.js 16.10 or later. 3. Configuration: Double-check your nuxt.config.ts file to ensure there are no conflicting settings that might interfere with the build process. Particularly, make sure you haven't accidentally set ssr: false or target: 'static', which could affect the server output. 4. Clean Build: Try removing the .nuxt and .output directories, then run npm cache clean --force followed by npm install and npm run build to ensure a clean build. 5. Nitro Preset: Verify that you're using the correct Nitro preset. For a Node.js server, you should use the node-server preset. You can add this to your nuxt.config.ts:
export default defineNuxtConfig({
nitro: {
preset: 'node-server'
}
})

export default defineNuxtConfig({
nitro: {
preset: 'node-server'
}
})

6. File System Permissions: Ensure that your build process has the necessary permissions to create files in the .output directory. 7. Antivirus Software: As mentioned in one of the GitHub issues, sometimes antivirus software can interfere with the build process. Try temporarily disabling your antivirus or adding exceptions for your project directory. If none of these solutions work, you might want to try creating a minimal reproduction of your project to isolate the issue. This can help identify if the problem is specific to your project configuration or if it's a more general Nuxt issue. If the problem persists, consider opening an issue on the Nuxt GitHub repository (https://github.com/nuxt/nuxt) with a detailed description of your setup and the steps to reproduce the issue. Nuxt Deployment Documentation (https://nuxt.com/docs/getting-started/deployment) GitHub Issue: Nuxt3 build .output folder remains empty (https://stackoverflow.com/questions/78366245) ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.aiβ€’2w ago
<@578603590927646754> Kapa.ai is still learning and improving, please let me know how I did by reacting below.
Want results from more Discord servers?
Add your server