Nuxt 部署在 heroku 错误 找不到模块'defu' 从'/app'



关于StackOverflow的第一个问题,所以请原谅我对代码和这里的无知。所以我想在heroku上部署下一个应用。到目前为止,我有一个工作的版本,但经过许多本地更改后,一个新的部署不工作。我用npm run build在本地运行这个应用,然后用npm run start,它工作得很好。但是当我使用

部署时
git push heroku development:master

到heroku页面不工作,日志显示如下:

2022-06-06T16:10:53.395913+00:00 app[web.1]:  ERROR  Cannot find module 'defu' from '/app'
2022-06-06T16:10:53.395914+00:00 app[web.1]: 
2022-06-06T16:10:53.395915+00:00 app[web.1]:   at Function.resolveSync [as sync] (node_modules/resolve/lib/sync.js:111:15)
2022-06-06T16:10:53.395915+00:00 app[web.1]:   at node_modules/vue-server-renderer/build.prod.js:1:77905
2022-06-06T16:10:53.395916+00:00 app[web.1]:   at Object.<anonymous> (webpack:/external "defu":1:0)
2022-06-06T16:10:53.395916+00:00 app[web.1]:   at __webpack_require__ (webpack/bootstrap:25:0)
2022-06-06T16:10:53.395916+00:00 app[web.1]:   at Module.<anonymous> (server.js:5594:22)
2022-06-06T16:10:53.395917+00:00 app[web.1]:   at __webpack_require__ (webpack/bootstrap:25:0)
2022-06-06T16:10:53.395917+00:00 app[web.1]:   at Object.<anonymous> (server.js:1940:18)
2022-06-06T16:10:53.395917+00:00 app[web.1]:   at __webpack_require__ (webpack/bootstrap:25:0)
2022-06-06T16:10:53.395918+00:00 app[web.1]:   at server.js:118:18
2022-06-06T16:10:53.395918+00:00 app[web.1]:   at Object.<anonymous> (server.js:121:10)

我无法找到任何相关的东西,所以任何帮助都会很感激。由于

编辑如果有帮助的话,这是我的包裹。

{
"name": "rutero-front",
"version": "1.0.0",
"private": true,
"scripts": {
"dev": "nuxt",
"build": "nuxt build",
"start": "nuxt start",
"generate": "nuxt generate"
},
"dependencies": {
"@fortawesome/fontawesome-svg-core": "^6.1.1",
"@fortawesome/free-brands-svg-icons": "^6.1.1",
"@fortawesome/free-solid-svg-icons": "^6.1.1",
"@fortawesome/vue-fontawesome": "^2.0.6",
"@nuxtjs/auth-next": "5.0.0-1648802546.c9880dc",
"@nuxtjs/axios": "^5.13.6",
"@nuxtjs/fontawesome": "^1.1.2",
"bootstrap": "^4.6.1",
"bootstrap-vue": "^2.22.0",
"core-js": "^3.19.3",
"node-sass": "^6.0.1",
"nuxt": "^2.15.8",
"v-calendar": "^2.4.1",
"vue": "^2.6.14",
"vue-burger-menu": "^2.0.5",
"vue-feather-icons": "^5.1.0",
"vue-flux": "^6.4.0",
"vue-iframes": "^0.0.19",
"vue-server-renderer": "^2.6.14",
"vue-smooth-reflow": "^0.1.12",
"vue-star-rating": "^1.7.0",
"vue-template-compiler": "^2.6.14",
"vue2-google-maps": "^0.10.7",
"webpack": "^4.46.0"
},
"devDependencies": {
"@nuxt/postcss8": "^1.1.3",
"@nuxtjs/style-resources": "^1.2.1",
"autoprefixer": "10.4.5",
"fibers": "^5.0.1",
"node-sass": "^6.0.1",
"postcss": "^8.4.12",
"sass-loader": "^10.2.1",
"tailwindcss": "^3.0.24"
}
}
export default {
// Global page headers: https://go.nuxtjs.dev/config-head
head: {
title: 'rutero-front',
htmlAttrs: {
lang: 'en'
},
meta: [
{ charset: 'utf-8' },
{ name: 'viewport', content: 'width=device-width, initial-scale=1' },
{ hid: 'description', name: 'description', content: '' },
{ name: 'format-detection', content: 'telephone=no' }
],
link: [
{ rel: 'icon', type: 'image/x-icon', href: '/favicon.png' }
]
},
// Global CSS: https://go.nuxtjs.dev/config-css
css: [
'@/assets/css/main.css',
],
// Plugins to run before rendering page: https://go.nuxtjs.dev/config-plugins
plugins: [
{ src: '~plugins//vue-burger-menu', mode: 'client' },
{ src: '~/plugins/star-rating.js', mode: 'client'},
{ src: '~/plugins/vue-google-maps.js' },
{ src: '~plugins/v-calendar.js', mode: 'client' },
{ src: '~/plugins/vue-iframes.js', mode: 'client' },
'@/plugins/bootstrap-vue',
{ src: '~/node_modules/vue-flux', mode: 'client' }
],
// Auto import components: https://go.nuxtjs.dev/config-components
components: true,
// Modules for dev and build (recommended): https://go.nuxtjs.dev/config-modules
buildModules: [
'@nuxtjs/fontawesome',
'@nuxt/postcss8',
],
fontawesome: {
component: 'fa',
icons:{
solid:true,
brands:true
}
},
// Modules: https://go.nuxtjs.dev/config-modules
modules: [
// https://go.nuxtjs.dev/axios
'@nuxtjs/axios',
'@nuxtjs/auth-next'
],


// Axios module configuration: https://go.nuxtjs.dev/config-axios
axios: {
// Workaround to avoid enforcing hard-coded localhost:3000: https://github.com/nuxt-community/axios-module/issues/308
baseURL: "http://localhost:8080",
},
// Build Configuration: https://go.nuxtjs.dev/config-build
build: {
postcss: {
plugins: {
'tailwindcss/nesting': {},
tailwindcss: './tailwind.config.js',
autoprefixer: {},
},
},
transpile: [/^vue2-google-maps($|/)/],
}
}

好的,所以如果有人有同样的问题,这更像是一个解决方案。显然这和bootstrap有关。我在包上有一个奇怪的bootstrap- value和bootstrap配置。json文件。

我设法部署到heroku,当我删除所有与bootstrap有关的东西时,错误并没有出现,只是保留了bootstrap- value对包的依赖。在nuext .config.js的modules小节中,有一行'bootstrap-vue/next '。

删除。next, package-lock。Json和node-modules文件夹,然后运行NPM install。一些使用bootstrap的组件现在看起来很糟糕,但至少应用程序可以部署在heroku和本地。

还添加了env变量NPM_CONFIG_PRODUCTION,并在heroku上将其设置为false,因为bootstrap的一些依赖(fibers, autoprefixer等)在devDependencies中,我认为它们也需要用于bootstrap-vue。

我仍然会玩,看看问题是什么。但是,是的,它的引导。

希望这能帮助到一些人。

相关内容

  • 没有找到相关文章

最新更新