Heroku 'sh: 1: next: not found'

6

请帮忙,我在Heroku部署我的Next.js应用程序时遇到了问题,但本地运行正常。

以下是来自Heroku的日志和我的package.json文件。

日志:

2021-08-13T07:26:20.752659+00:00 app[web.1]:
2021-08-13T07:26:20.752685+00:00 app[web.1]: > @ start /app
2021-08-13T07:26:20.752688+00:00 app[web.1]: > next start -p $PORT
2021-08-13T07:26:20.752689+00:00 app[web.1]:
2021-08-13T07:26:20.763505+00:00 app[web.1]: sh: 1: next: not found
2021-08-13T07:26:20.769117+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2021-08-13T07:26:20.769496+00:00 app[web.1]: npm ERR! syscall spawn
2021-08-13T07:26:20.769568+00:00 app[web.1]: npm ERR! file sh
2021-08-13T07:26:20.769636+00:00 app[web.1]: npm ERR! errno ENOENT
2021-08-13T07:26:20.772506+00:00 app[web.1]: npm ERR! @ start: `next start -p $PORT`
2021-08-13T07:26:20.772533+00:00 app[web.1]: npm ERR! spawn ENOENT

package.json:

{
  "private": true,
  "scripts": {
    "dev": "next dev",
    "build": "next build",
    "start": "next start -p $PORT"
  },
  "dependencies": {
    "@heroicons/react": "^1.0.3",
    "next": "latest",
    "react": "^17.0.2",
    "react-dom": "^17.0.2",
    "tailwind-scrollbar-hide": "^1.0.3"
  },
  "devDependencies": {
    "autoprefixer": "^10.2.6",
    "postcss": "^8.3.5",
    "tailwindcss": "^2.2.4"
  }
}

2
尝试在 package.json 中使用特定版本的 next,例如 "next": "^11.1.0" - juliomalves
谢谢,这解决了我的问题,我的应用现在已经部署在Heroku上了。 - Cuado
2个回答

3

这是因为您在Heroku上的应用程序没有安装“next npm”

解决方法:

  • 访问您的项目目录
  • 打开终端
  • 执行命令npm install next

1

你需要确保它安装了npm依赖项。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接