Home  >  Q&A  >  body text

Heroku/Nuxt: nuxt command not found (sh: 1: nuxt: not found)

I ran into a problem where I ended up deploying a server side nuxt app with express server to Heroku. The build succeeds, but when trying to launch, I get the following error:

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 脚本执行失败。

I'm not sure where I went wrong. Do I need to build it before deploying using Heroku cli? Is this a problem with my express server (since it says it failed at nuxt-express)? I'm just not sure what's going on, if anyone could help me that would be very helpful! Thanks!

If it helps, here is my 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粉757556355P粉757556355348 days ago848

reply all(1)I'll reply

  • P粉510127741

    P粉5101277412023-11-06 15:07:41

    Try changing your startup script to point to a path to nuxt/bin and then provide

    If you are still having issues, consider adding the -c flag along with a relative path to the nuxt.config.js file.

    The same goes for builds.

     "scripts": {
        "dev": "nuxt",
        "build": "nuxt build",
        "start": "nuxt start",
        "generate": "nuxt generate",
        "heroku-postbuild": "npm run build"
      },
    

    change to

     "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"
      },
    

    reply
    0
  • Cancelreply