我遇到了一个问题,我最终部署了一个带有express服务器的服务器端nuxt应用程序到Heroku。构建成功,但当尝试启动时,出现以下错误:
2021-07-29T18:13:38.000000+00:00 app[api]: 构建成功 2021-07-29T18:13:42.050534+00:00 heroku[web.1]: 进程以状态1退出 2021-07-29T18:13:42.139623+00:00 heroku[web.1]: 状态从启动变为崩溃 2021-07-29T18:13:41.793565+00:00 app[web.1]: 2021-07-29T18:13:41.793587+00:00 app[web.1]: > nuxt-express@1.0.0 start /app 2021-07-29T18:13:41.793588+00:00 app[web.1]: > nuxt start 2021-07-29T18:13:41.793588+00:00 app[web.1]: 2021-07-29T18:13:41.814774+00:00 app[web.1]: sh: 1: nuxt: 未找到 2021-07-29T18:13:41.822159+00:00 app[web.1]: npm ERR! code ELIFECYCLE 2021-07-29T18:13:41.822579+00:00 app[web.1]: npm ERR! syscall spawn 2021-07-29T18:13:41.822774+00:00 app[web.1]: npm ERR! file sh 2021-07-29T18:13:41.823001+00:00 app[web.1]: npm ERR! errno ENOENT 2021-07-29T18:13:41.834748+00:00 app[web.1]: npm ERR! nuxt-express@1.0.0 start: `nuxt start` 2021-07-29T18:13:41.834966+00:00 app[web.1]: npm ERR! spawn ENOENT 2021-07-29T18:13:41.835206+00:00 app[web.1]: npm ERR! 2021-07-29T18:13:41.835433+00:00 app[web.1]: npm ERR! nuxt-express@1.0.0 start 脚本执行失败。
我不确定我在哪里出错了。我是否需要在使用Heroku cli部署之前构建它?这是我的express服务器的问题吗(因为它说在nuxt-express处失败了)?我只是不确定发生了什么,如果有人能帮助我,那将对我非常有帮助!谢谢!
如果有帮助的话,这是我的package.json:
{ "name": "p-live", "version": "1.0.0", "private": true, "scripts": { "dev": "nuxt", "build": "nuxt build", "start": "nuxt start", "generate": "nuxt generate", "heroku-postbuild": "npm run build" }, "dependencies": { "@nuxt/http": "latest", "@nuxtjs/firebase": "^7.5.0", "cookie-universal-nuxt": "^2.1.5", "dotenv": "^10.0.0", "express": "latest", "firebase": "^8.3.1", "jsforce": "^1.10.1", "nuxt": "latest" }, "devDependencies": { "@nuxtjs/moment": "^1.6.1", "@nuxtjs/pwa": "^3.3.5", "@nuxtjs/tailwindcss": "^3.4.2", "@tailwindcss/custom-forms": "^0.2.1", "@tailwindcss/postcss7-compat": "^2.0.3", "autoprefixer": "^9.8.6", "babel-eslint": "^10.1.0", "eslint": "^7.20.0", "eslint-plugin-nuxt": "^2.0.0", "postcss": "^7.0.35", "tailwindcss": "npm:@tailwindcss/postcss7-compat@^2.0.3" } }
P粉5101277412023-11-06 15:07:41
尝试将您的启动脚本更改为指向nuxt/bin
的路径,然后提供
如果您仍然遇到问题,可以考虑添加-c
标志以及指向nuxt.config.js
文件的相对路径。
对于构建也是一样。
"scripts": { "dev": "nuxt", "build": "nuxt build", "start": "nuxt start", "generate": "nuxt generate", "heroku-postbuild": "npm run build" },
更改为
"scripts": { "dev": "nuxt", "build": "node_modules/nuxt/bin/nuxt.js build -c ./nuxt.config.js", "start": "node_modules/nuxt/bin/nuxt.js start -c ./nuxt.config.js", "generate": "nuxt generate", "heroku-postbuild": "npm run build" },