heroku 运行npm启动时“index.js未找到”,错误!代码ELIFECYCLE和ENOENT

pkln4tw6  于 2023-03-12  发布在  其他
关注(0)|答案(2)|浏览(172)

我想通过Heroku运行一个Discord机器人。
但是我每次运行npm start都会收到npm错误代码,bot在Discord上保持离线状态,我已经试过npm cache clean --forcermdir /S /Q node_modulesnpm install,但是这些都不起作用。
以下是控制台日志:

2021-05-09T11:37:13.126499+00:00 app[web.1]: npm ERR!     /app/.npm/_logs/2021-05-09T11_37_13_077Z-debug.log
2021-05-09T11:37:13.225562+00:00 heroku[web.1]: Process exited with status 1
2021-05-09T11:37:13.398582+00:00 heroku[web.1]: State changed from starting to crashed
2021-05-09T11:37:20.322275+00:00 app[api]: Starting process with command `npm start` by user <email redacted>
2021-05-09T11:37:23.274907+00:00 heroku[run.4911]: State changed from starting to up
2021-05-09T11:37:23.427148+00:00 heroku[run.4911]: Awaiting client
2021-05-09T11:37:23.726119+00:00 heroku[run.4911]: Starting process with command `npm start`
2021-05-09T11:37:28.678579+00:00 heroku[run.4911]: Process exited with status 1
2021-05-09T11:37:28.742179+00:00 heroku[run.4911]: State changed from up to complete
2021-05-09T11:44:03.004685+00:00 heroku[web.1]: State changed from crashed to starting
2021-05-09T11:44:05.335454+00:00 heroku[web.1]: Starting process with command `npm start`
2021-05-09T11:44:08.088534+00:00 heroku[web.1]: Process exited with status 1
2021-05-09T11:44:08.229000+00:00 heroku[web.1]: State changed from starting to crashed
2021-05-09T11:44:08.232296+00:00 heroku[web.1]: State changed from crashed to starting
2021-05-09T11:44:08.000901+00:00 app[web.1]: 
2021-05-09T11:44:08.000925+00:00 app[web.1]: > CalculatorBot@1.0.0 start /app
2021-05-09T11:44:08.000925+00:00 app[web.1]: > index.js
2021-05-09T11:44:08.000925+00:00 app[web.1]: 
2021-05-09T11:44:08.005333+00:00 app[web.1]: sh: 1: index.js: not found
2021-05-09T11:44:08.012134+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2021-05-09T11:44:08.012381+00:00 app[web.1]: npm ERR! syscall spawn
2021-05-09T11:44:08.012474+00:00 app[web.1]: npm ERR! file sh
2021-05-09T11:44:08.012618+00:00 app[web.1]: npm ERR! errno ENOENT
2021-05-09T11:44:08.016105+00:00 app[web.1]: npm ERR! CalculatorBot@1.0.0 start: `index.js`
2021-05-09T11:44:08.016163+00:00 app[web.1]: npm ERR! spawn ENOENT
2021-05-09T11:44:08.016238+00:00 app[web.1]: npm ERR! 
2021-05-09T11:44:08.016285+00:00 app[web.1]: npm ERR! Failed at the CalculatorBot@1.0.0 start script.
2021-05-09T11:44:08.016364+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2021-05-09T11:44:08.024564+00:00 app[web.1]: 
2021-05-09T11:44:08.024647+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2021-05-09T11:44:08.024701+00:00 app[web.1]: npm ERR!     /app/.npm/_logs/2021-05-09T11_44_08_016Z-debug.log
2021-05-09T11:44:11.422108+00:00 heroku[web.1]: Starting process with command `npm start`
2021-05-09T11:44:14.301131+00:00 heroku[web.1]: Process exited with status 1
2021-05-09T11:44:14.438297+00:00 heroku[web.1]: State changed from starting to crashed
2021-05-09T11:44:14.212635+00:00 app[web.1]: 
2021-05-09T11:44:14.212651+00:00 app[web.1]: > CalculatorBot@1.0.0 start /app
2021-05-09T11:44:14.212652+00:00 app[web.1]: > index.js
2021-05-09T11:44:14.212652+00:00 app[web.1]: 
2021-05-09T11:44:14.217415+00:00 app[web.1]: sh: 1: index.js: not found
2021-05-09T11:44:14.225315+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2021-05-09T11:44:14.225593+00:00 app[web.1]: npm ERR! syscall spawn
2021-05-09T11:44:14.225710+00:00 app[web.1]: npm ERR! file sh
2021-05-09T11:44:14.225853+00:00 app[web.1]: npm ERR! errno ENOENT
2021-05-09T11:44:14.229827+00:00 app[web.1]: npm ERR! CalculatorBot@1.0.0 start: `index.js`
2021-05-09T11:44:14.229941+00:00 app[web.1]: npm ERR! spawn ENOENT
2021-05-09T11:44:14.230071+00:00 app[web.1]: npm ERR! 
2021-05-09T11:44:14.230234+00:00 app[web.1]: npm ERR! Failed at the CalculatorBot@1.0.0 start script.
2021-05-09T11:44:14.230359+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2021-05-09T11:44:14.237148+00:00 app[web.1]: 
2021-05-09T11:44:14.237336+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2021-05-09T11:44:14.237482+00:00 app[web.1]: npm ERR!     /app/.npm/_logs/2021-05-09T11_44_14_231Z-debug.log

我的package.json

{
  "name": "CalculatorBot",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "start": "index.js"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "discord.js": "^12.5.3",
    "math": "0.0.3"
  }
}

你觉得我该怎么做才能解决这个问题?

nimxete2

nimxete21#

package.json更改为以下内容

......
 "start": "node index.js"
.......
huus2vyu

huus2vyu2#

在您的Procfile中,将该行代码与我在此处列出的代码相同

web: node index.js

现在再次尝试使用Heroku部署您的WebApp。

相关问题