Heroku/Nuxt: 找不到nuxt指令(sh: 1: nuxt: not found)
P粉757556355
P粉757556355 2023-11-05 18:59:02
0
1
901

我遇到了一個問題,我最終部署了一個帶有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粉757556355
P粉757556355

全部回覆(1)
P粉510127741

嘗試將您的啟動腳本變更為指向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"
  },
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板