NUXT 3生产模式抛出“未定义”。
我正在非服务器模式下运行NUXT 3应用程序ssr:false
。它在开发模式下运行良好,但是一旦我通过npm run构建构建
,然后通过node .Output/server/index.mjs
启动服务器,就会出现使用错误500屏幕说进程未定义
没有调试信息,也没有控制台错误,也没有错误登录Heroku。
这是我的nuxt配置:
import { defineNuxtConfig } from 'nuxt'
// https://v3.nuxtjs.org/api/configuration/nuxt.config
export default defineNuxtConfig({
css: ['vuetify/lib/styles/main.sass', 'mdi/css/materialdesignicons.min.css', '@/assets/sass/main.sass'],
build: {
transpile: ['vuetify'],
},
// vite: {
// define: {
// 'process.env.DEBUG': false,
// },
// },
modules: [
['@nuxtjs/axios', { proxyHeaders: false }],
'@pinia/nuxt'
],
ssr: false // Disable server side rendering
})
如您所见,我还禁用了vite
零件,因为这是我代码中Process
甚至引用的唯一位置。
这是我看到的屏幕:
我在做什么错?
I am running a nuxt 3 app in non server mode ssr: false
. It runs fine in development mode but as soon as I build the app via npm run build
and then starting the server via node .output/server/index.mjs
it comes up with a Error 500 screen saying process is not defined
There is no debug information, no console error and no error log on heroku either.
Here is my nuxt config:
import { defineNuxtConfig } from 'nuxt'
// https://v3.nuxtjs.org/api/configuration/nuxt.config
export default defineNuxtConfig({
css: ['vuetify/lib/styles/main.sass', 'mdi/css/materialdesignicons.min.css', '@/assets/sass/main.sass'],
build: {
transpile: ['vuetify'],
},
// vite: {
// define: {
// 'process.env.DEBUG': false,
// },
// },
modules: [
['@nuxtjs/axios', { proxyHeaders: false }],
'@pinia/nuxt'
],
ssr: false // Disable server side rendering
})
as you can see I also disabled the vite
part as this is the only place in my code where process
is even referenced.
This is the screen I see:
What am I doing wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
问题似乎在NUXT Axios模块上。
卸下模块并使用默认轴似乎使其正常工作。
Problem seems to be on the nuxt axios module.
Removing the module and using default axios it seems to make it work.
我删除了
@nuxtjs/axios
模块,只使用原始axios
。有效。I removed
@nuxtjs/axios
module and just use originalaxios
. that works.当我用纱线添加进程时,我可以解决我的情况,然后添加为插件。
所以我这样做了:
然后在我的插件文件夹上创建一个process.ts文件:
插件/process.ts
< img src =“ https://i.sstatic.net/6znnh.png” alt =”输入图像描述在这里“>
并在我的nuxt.config.ts上添加,我添加了插件部分
在该项目上,我使用的是NUXT 3 + VUE 3 + VUETIFY 3。
然后,可以在Vercel和Netilify中部署。
i solve my case when i add process with yarn, and then add as a plugin.
So i did this:
and then create a process.ts file on my plugins folder:
plugins/process.ts
and add on my nuxt.config.ts, i added the plugins section
On that project i am using Nuxt 3 + Vue 3 + Vuetify 3.
And on that way, was possible to deploy in Vercel and Netilify.