コード
node.js
1const express = require("express"); 2const { Client } = require("discord.js"); 3 4require("./Modules/Console.js"); 5const time = require("./Modules/Time.js"); 6const bot = require("./Modules/Bot.js"); 7const logger = require("./Modules/Logger.js"); 8const activity = require("./Modules/Activity.js"); 9const statistics = require("./Modules/Statistics/index.js");
こんな感じのパスを指定してrequire
しているのですが、herokuでデプロイするとモジュールが見つかりませんとエラーが出ます。
エラー内容
console
1> heroku logs --tail 2(略) 32021-04-24T00:46:07.173782+00:00 heroku[web.1]: State changed from crashed to starting 42021-04-24T00:46:11.226086+00:00 heroku[web.1]: Starting process with command `npm start` 52021-04-24T00:46:13.128495+00:00 app[web.1]: 62021-04-24T00:46:13.128516+00:00 app[web.1]: > <アプリ名>@1.0.0 start /app 72021-04-24T00:46:13.128516+00:00 app[web.1]: > node server.js 82021-04-24T00:46:13.128517+00:00 app[web.1]: 92021-04-24T00:46:13.318618+00:00 app[web.1]: internal/modules/cjs/loader.js:883 102021-04-24T00:46:13.318619+00:00 app[web.1]: throw err; 112021-04-24T00:46:13.318619+00:00 app[web.1]: ^ 122021-04-24T00:46:13.318620+00:00 app[web.1]: 132021-04-24T00:46:13.318620+00:00 app[web.1]: Error: Cannot find module './Modules/Console.js' 142021-04-24T00:46:13.318620+00:00 app[web.1]: Require stack: 152021-04-24T00:46:13.318621+00:00 app[web.1]: - /app/server.js 162021-04-24T00:46:13.318621+00:00 app[web.1]: at Function.Module._resolveFilename (internal/modules/cjs/loader.js:880:15) 172021-04-24T00:46:13.318622+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:725:27) 182021-04-24T00:46:13.318622+00:00 app[web.1]: at Module.require (internal/modules/cjs/loader.js:952:19) 192021-04-24T00:46:13.318622+00:00 app[web.1]: at require (internal/modules/cjs/helpers.js:88:18) 202021-04-24T00:46:13.318622+00:00 app[web.1]: at Object.<anonymous> (/app/server.js:5:1) 212021-04-24T00:46:13.318623+00:00 app[web.1]: at Module._compile (internal/modules/cjs/loader.js:1063:30) 222021-04-24T00:46:13.318623+00:00 app[web.1]: at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10) 232021-04-24T00:46:13.318623+00:00 app[web.1]: at Module.load (internal/modules/cjs/loader.js:928:32) 242021-04-24T00:46:13.318623+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:769:14) 252021-04-24T00:46:13.318624+00:00 app[web.1]: at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12) { 262021-04-24T00:46:13.318624+00:00 app[web.1]: code: 'MODULE_NOT_FOUND', 272021-04-24T00:46:13.318624+00:00 app[web.1]: requireStack: [ '/app/server.js' ] 282021-04-24T00:46:13.318624+00:00 app[web.1]: } 292021-04-24T00:46:13.326122+00:00 app[web.1]: npm ERR! code ELIFECYCLE 302021-04-24T00:46:13.326316+00:00 app[web.1]: npm ERR! errno 1 312021-04-24T00:46:13.329035+00:00 app[web.1]: npm ERR! <アプリ名>@1.0.0 start: `node server.js` 322021-04-24T00:46:13.329086+00:00 app[web.1]: npm ERR! Exit status 1 332021-04-24T00:46:13.329138+00:00 app[web.1]: npm ERR! 342021-04-24T00:46:13.329185+00:00 app[web.1]: npm ERR! Failed at the <アプリ名>@1.0.0 start script. 352021-04-24T00:46:13.329217+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above. 362021-04-24T00:46:13.331719+00:00 app[web.1]: 372021-04-24T00:46:13.331803+00:00 app[web.1]: npm ERR! A complete log of this run can be found in: 382021-04-24T00:46:13.331840+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2021-04-24T00_46_13_329Z-debug.log 392021-04-24T00:46:13.391747+00:00 heroku[web.1]: Process exited with status 1 402021-04-24T00:46:13.451263+00:00 heroku[web.1]: State changed from starting to crashed 412021-04-24T00:46:13.455899+00:00 heroku[web.1]: State changed from crashed to starting 422021-04-24T00:46:15.000000+00:00 app[api]: Build succeeded 432021-04-24T00:46:17.394696+00:00 heroku[web.1]: Starting process with command `npm start` 442021-04-24T00:46:19.481988+00:00 app[web.1]: 452021-04-24T00:46:19.481999+00:00 app[web.1]: > <アプリ名>@1.0.0 start /app 462021-04-24T00:46:19.482000+00:00 app[web.1]: > node server.js 472021-04-24T00:46:19.482000+00:00 app[web.1]: 482021-04-24T00:46:19.660277+00:00 app[web.1]: internal/modules/cjs/loader.js:883 492021-04-24T00:46:19.660278+00:00 app[web.1]: throw err; 502021-04-24T00:46:19.660279+00:00 app[web.1]: ^ 512021-04-24T00:46:19.660279+00:00 app[web.1]: 522021-04-24T00:46:19.660280+00:00 app[web.1]: Error: Cannot find module './Modules/Console.js' 532021-04-24T00:46:19.660280+00:00 app[web.1]: Require stack: 542021-04-24T00:46:19.660280+00:00 app[web.1]: - /app/server.js 552021-04-24T00:46:19.660281+00:00 app[web.1]: at Function.Module._resolveFilename (internal/modules/cjs/loader.js:880:15) 562021-04-24T00:46:19.660281+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:725:27) 572021-04-24T00:46:19.660281+00:00 app[web.1]: at Module.require (internal/modules/cjs/loader.js:952:19) 582021-04-24T00:46:19.660284+00:00 app[web.1]: at require (internal/modules/cjs/helpers.js:88:18) 592021-04-24T00:46:19.660285+00:00 app[web.1]: at Object.<anonymous> (/app/server.js:5:1) 602021-04-24T00:46:19.660285+00:00 app[web.1]: at Module._compile (internal/modules/cjs/loader.js:1063:30) 612021-04-24T00:46:19.660285+00:00 app[web.1]: at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10) 622021-04-24T00:46:19.660285+00:00 app[web.1]: at Module.load (internal/modules/cjs/loader.js:928:32) 632021-04-24T00:46:19.660286+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:769:14) 642021-04-24T00:46:19.660286+00:00 app[web.1]: at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12) { 652021-04-24T00:46:19.660286+00:00 app[web.1]: code: 'MODULE_NOT_FOUND', 662021-04-24T00:46:19.660286+00:00 app[web.1]: requireStack: [ '/app/server.js' ] 672021-04-24T00:46:19.660286+00:00 app[web.1]: } 682021-04-24T00:46:19.668100+00:00 app[web.1]: npm ERR! code ELIFECYCLE 692021-04-24T00:46:19.668288+00:00 app[web.1]: npm ERR! errno 1 702021-04-24T00:46:19.670837+00:00 app[web.1]: npm ERR! <アプリ名>@1.0.0 start: `node server.js` 712021-04-24T00:46:19.670889+00:00 app[web.1]: npm ERR! Exit status 1 722021-04-24T00:46:19.670960+00:00 app[web.1]: npm ERR! 732021-04-24T00:46:19.671005+00:00 app[web.1]: npm ERR! Failed at the <アプリ名>@1.0.0 start script. 742021-04-24T00:46:19.671047+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above. 75(略)
こんな感じでエラーになります。クライアント(自分のPC)では実行はできるのになぜherokuではエラーが出るのでしょうか?
Herokuに対象のファイルがアップロードされているか確認してください
確認をする方法があるのですか。よろしければ確認方法を教えてくれないでしょうか?
Running bash on ⬢ <アプリ名>... up, run.5758 (Free)
~ $
と出ました
使い方を確認しました。
どうやら存在しないと怒られました。
あなたの回答
tips
プレビュー