Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/heroku/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js 部署+;使用CLI客户端_Node.js_Heroku_Client_Command Line Interface - Fatal编程技术网

Node.js 部署+;使用CLI客户端

Node.js 部署+;使用CLI客户端,node.js,heroku,client,command-line-interface,Node.js,Heroku,Client,Command Line Interface,我正在从事一个项目,其中必须有一个Node.js CLI客户端与Heroku服务器通信 我尝试部署一个简单的聊天应用程序示例,以确保一切正常,但遇到Heroku错误,该错误表示“应用程序中出现错误,无法为您的页面提供服务。如果您是应用程序所有者,请检查日志以了解详细信息。您可以使用命令Heroku logs--tail从Heroku CLI执行此操作” 以下是我在运行上述命令时的Heroku日志,我确信错误与服务器在部署时无法加载套接字io模块有关: 2021-04-26T00:05:05.31

我正在从事一个项目,其中必须有一个Node.js CLI客户端与Heroku服务器通信

我尝试部署一个简单的聊天应用程序示例,以确保一切正常,但遇到Heroku错误,该错误表示“应用程序中出现错误,无法为您的页面提供服务。如果您是应用程序所有者,请检查日志以了解详细信息。您可以使用命令Heroku logs--tail从Heroku CLI执行此操作”

以下是我在运行上述命令时的Heroku日志,我确信错误与服务器在部署时无法加载
套接字io
模块有关:

2021-04-26T00:05:05.310536+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2021-04-26T00:05:05.310536+00:00 app[web.1]: npm ERR!     /app/.npm/_logs/2021-04-26T00_05_05_288Z-debug.log
2021-04-26T00:05:05.386444+00:00 heroku[web.1]: Process exited with status 1
2021-04-26T00:05:05.490453+00:00 heroku[web.1]: State changed from starting to crashed
2021-04-26T00:05:05.494874+00:00 heroku[web.1]: State changed from crashed to starting
2021-04-26T00:05:08.142848+00:00 heroku[web.1]: Starting process with command `npm start`
2021-04-26T00:05:11.291774+00:00 app[web.1]:
2021-04-26T00:05:11.291802+00:00 app[web.1]: > test@1.0.0 start /app
2021-04-26T00:05:11.291802+00:00 app[web.1]: > node index.js
2021-04-26T00:05:11.291802+00:00 app[web.1]:
2021-04-26T00:05:11.374875+00:00 app[web.1]: internal/modules/cjs/loader.js:883
2021-04-26T00:05:11.374878+00:00 app[web.1]: throw err;
2021-04-26T00:05:11.374879+00:00 app[web.1]: ^
2021-04-26T00:05:11.374879+00:00 app[web.1]:
2021-04-26T00:05:11.374880+00:00 app[web.1]: Error: Cannot find module 'socket.io'
2021-04-26T00:05:11.374880+00:00 app[web.1]: Require stack:
2021-04-26T00:05:11.374880+00:00 app[web.1]: - /app/index.js
2021-04-26T00:05:11.374881+00:00 app[web.1]: at Function.Module._resolveFilename (internal/modules/cjs/loader.js:880:15)
2021-04-26T00:05:11.374881+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:725:27)
2021-04-26T00:05:11.374882+00:00 app[web.1]: at Module.require (internal/modules/cjs/loader.js:952:19)
2021-04-26T00:05:11.374882+00:00 app[web.1]: at require (internal/modules/cjs/helpers.js:88:18)
2021-04-26T00:05:11.374882+00:00 app[web.1]: at Object.<anonymous> (/app/index.js:2:12)
2021-04-26T00:05:11.374883+00:00 app[web.1]: at Module._compile (internal/modules/cjs/loader.js:1063:30)
2021-04-26T00:05:11.374883+00:00 app[web.1]: at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
2021-04-26T00:05:11.374883+00:00 app[web.1]: at Module.load (internal/modules/cjs/loader.js:928:32)
2021-04-26T00:05:11.374887+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:769:14)
2021-04-26T00:05:11.374888+00:00 app[web.1]: at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12) {
2021-04-26T00:05:11.374888+00:00 app[web.1]: code: 'MODULE_NOT_FOUND',
2021-04-26T00:05:11.374889+00:00 app[web.1]: requireStack: [ '/app/index.js' ]
2021-04-26T00:05:11.374889+00:00 app[web.1]: }
2021-04-26T00:05:11.407116+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2021-04-26T00:05:11.407516+00:00 app[web.1]: npm ERR! errno 1
2021-04-26T00:05:11.416214+00:00 app[web.1]: npm ERR! test@1.0.0 start: `node index.js`
2021-04-26T00:05:11.416464+00:00 app[web.1]: npm ERR! Exit status 1
2021-04-26T00:05:11.416760+00:00 app[web.1]: npm ERR!
2021-04-26T00:05:11.416976+00:00 app[web.1]: npm ERR! Failed at the test@1.0.0 start script.
2021-04-26T00:05:11.417532+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2021-04-26T00:05:11.430755+00:00 app[web.1]:
2021-04-26T00:05:11.431385+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2021-04-26T00:05:11.431600+00:00 app[web.1]: npm ERR!     /app/.npm/_logs/2021-04-26T00_05_11_418Z-debug.log
2021-04-26T00:05:11.505552+00:00 heroku[web.1]: Process exited with status 1
2021-04-26T00:05:11.580749+00:00 heroku[web.1]: State changed from starting to crashed
2021-04-26T00:05:13.627279+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=slingshot-test-nodejs.herokuapp.com request_id=41d7f800-0833-45ac-9a24-e9e984981929 fwd="24.196.239.75" dyno= connect= service= status=503 bytes= protocol=https
2021-04-26T00:05:13.811879+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=slingshot-test-nodejs.herokuapp.com request_id=de243ea9-c7e1-4a74-91bd-4da78834b085 fwd="24.196.239.75" dyno= connect= service= status=503 bytes= protocol=https
2021-04-26T00:13:06.000000+00:00 app[api]: Build started by user hbagalkote@gmail.com
2021-04-26T00:13:23.000000+00:00 app[api]: Build succeeded
2021-04-26T00:13:23.403605+00:00 app[api]: Deploy 12d7e839 by user hbagalkote@gmail.com
2021-04-26T00:13:23.403605+00:00 app[api]: Release v8 created by user hbagalkote@gmail.com
2021-04-26T00:13:23.552491+00:00 heroku[web.1]: State changed from crashed to starting
2021-04-26T00:13:26.818012+00:00 heroku[web.1]: Starting process with command `node index.js`
2021-04-26T00:13:29.914344+00:00 app[web.1]: internal/modules/cjs/loader.js:883
2021-04-26T00:13:29.914388+00:00 app[web.1]: throw err;
2021-04-26T00:13:29.914388+00:00 app[web.1]: ^
2021-04-26T00:13:29.914389+00:00 app[web.1]:
2021-04-26T00:13:29.914389+00:00 app[web.1]: Error: Cannot find module 'socket.io'
2021-04-26T00:13:29.914390+00:00 app[web.1]: Require stack:
2021-04-26T00:13:29.914390+00:00 app[web.1]: - /app/index.js
2021-04-26T00:13:29.914391+00:00 app[web.1]: at Function.Module._resolveFilename (internal/modules/cjs/loader.js:880:15)
2021-04-26T00:13:29.914391+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:725:27)
2021-04-26T00:13:29.914391+00:00 app[web.1]: at Module.require (internal/modules/cjs/loader.js:952:19)
2021-04-26T00:13:29.914392+00:00 app[web.1]: at require (internal/modules/cjs/helpers.js:88:18)
2021-04-26T00:13:29.914392+00:00 app[web.1]: at Object.<anonymous> (/app/index.js:2:12)
2021-04-26T00:13:29.914392+00:00 app[web.1]: at Module._compile (internal/modules/cjs/loader.js:1063:30)
2021-04-26T00:13:29.914392+00:00 app[web.1]: at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
2021-04-26T00:13:29.914393+00:00 app[web.1]: at Module.load (internal/modules/cjs/loader.js:928:32)
2021-04-26T00:13:29.914393+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:769:14)
2021-04-26T00:13:29.914394+00:00 app[web.1]: at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12) {
2021-04-26T00:13:29.914394+00:00 app[web.1]: code: 'MODULE_NOT_FOUND',
2021-04-26T00:13:29.914394+00:00 app[web.1]: requireStack: [ '/app/index.js' ]
2021-04-26T00:13:29.914395+00:00 app[web.1]: }
2021-04-26T00:13:29.974925+00:00 heroku[web.1]: Process exited with status 1
2021-04-26T00:13:30.067473+00:00 heroku[web.1]: State changed from starting to crashed
2021-04-26T00:13:32.450999+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=slingshot-test-nodejs.herokuapp.com request_id=37d17d3f-c2b0-4bca-b1ca-36eb952e09de fwd="24.196.239.75" dyno= connect= service= status=503 bytes= protocol=https
2021-04-26T00:13:32.618072+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=slingshot-test-nodejs.herokuapp.com request_id=13ff0bcf-2201-46d9-84ac-d05c91bd12ef fwd="24.196.239.75" dyno= connect= service= status=503 bytes= protocol=https
2021-04-26T00:16:34.224143+00:00 heroku[web.1]: State changed from crashed to starting
2021-04-26T00:16:36.722190+00:00 heroku[web.1]: Starting process with command `node index.js`
2021-04-26T00:16:38.725268+00:00 app[web.1]: internal/modules/cjs/loader.js:883
2021-04-26T00:16:38.725295+00:00 app[web.1]: throw err;
2021-04-26T00:16:38.725296+00:00 app[web.1]: ^
2021-04-26T00:16:38.725296+00:00 app[web.1]:
2021-04-26T00:16:38.725296+00:00 app[web.1]: Error: Cannot find module 'socket.io'
2021-04-26T00:16:38.725296+00:00 app[web.1]: Require stack:
2021-04-26T00:16:38.725297+00:00 app[web.1]: - /app/index.js
2021-04-26T00:16:38.725297+00:00 app[web.1]: at Function.Module._resolveFilename (internal/modules/cjs/loader.js:880:15)
2021-04-26T00:16:38.725297+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:725:27)
2021-04-26T00:16:38.725298+00:00 app[web.1]: at Module.require (internal/modules/cjs/loader.js:952:19)
2021-04-26T00:16:38.725298+00:00 app[web.1]: at require (internal/modules/cjs/helpers.js:88:18)
2021-04-26T00:16:38.725298+00:00 app[web.1]: at Object.<anonymous> (/app/index.js:2:12)
2021-04-26T00:16:38.725298+00:00 app[web.1]: at Module._compile (internal/modules/cjs/loader.js:1063:30)
2021-04-26T00:16:38.725299+00:00 app[web.1]: at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
2021-04-26T00:16:38.725299+00:00 app[web.1]: at Module.load (internal/modules/cjs/loader.js:928:32)
2021-04-26T00:16:38.725299+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:769:14)
2021-04-26T00:16:38.725300+00:00 app[web.1]: at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12) {
2021-04-26T00:16:38.725300+00:00 app[web.1]: code: 'MODULE_NOT_FOUND',
2021-04-26T00:16:38.725300+00:00 app[web.1]: requireStack: [ '/app/index.js' ]
2021-04-26T00:16:38.725301+00:00 app[web.1]: }
2021-04-26T00:16:38.775108+00:00 heroku[web.1]: Process exited with status 1
2021-04-26T00:16:38.832146+00:00 heroku[web.1]: State changed from starting to crashed
2021-04-26T00:17:40.388694+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=slingshot-test-nodejs.herokuapp.com request_id=f42d0aaf-a1db-4f6a-8888-063084139ca2 fwd="24.196.239.75" dyno= connect= service= status=503 bytes= protocol=https
2021-04-26T00:17:40.499806+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=slingshot-test-nodejs.herokuapp.com request_id=34f18224-8dfd-40aa-93db-78ad61880e63 fwd="24.196.239.75" dyno= connect= service= status=503 bytes= protocol=https
//客户端代码
//显然,这个localhost值不起作用,但是我应该改成什么呢?
var socket=require('socket.io客户端')('http://localhost:3000')
const repl=require('repl')
常量粉笔=需要(“粉笔”)
var username=null
socket.on('disconnect',function()){
socket.emit('disconnect')
})
socket.on('connect',()=>{
console.log(chalk.red('==开始聊天=='))
username=process.argv[2]
})
socket.on('消息',(数据)=>{
const{cmd,username}=data
log(chalk.green(用户名+':'+cmd.split(“\n”)[0]))
})
答复:开始({
提示:“”,
eval:(cmd)=>{
socket.send({cmd,username})
}
})

在部署过程中,
npm install
是否在任何时候运行?否,但我将procfile start命令改为
npm start
,现在我收到一个
错误R10(启动超时)->Web进程在启动后60秒内未能绑定到$PORT
错误。