2

I am hosting a university project on heroku and i need to host a django app which also needs an npm library but i searched alot on how to do this and eventualy i thought i got the hand of it but now i am getting this error:

2018-06-14T10:19:22.798022+00:00 app[web.1]:     throw err;

2018-06-14T10:19:22.798023+00:00 app[web.1]:     ^

2018-06-14T10:19:22.798024+00:00 app[web.1]: 

2018-06-14T10:19:22.798026+00:00 app[web.1]: Error: Cannot find module '/app/server.js'

2018-06-14T10:19:22.798028+00:00 app[web.1]:     at Function.Module._resolveFilename (module.js:547:15)

2018-06-14T10:19:22.798029+00:00 app[web.1]:     at Function.Module._load (module.js:474:25)

2018-06-14T10:19:22.798030+00:00 app[web.1]:     at Function.Module.runMain (module.js:693:10)

2018-06-14T10:19:22.798031+00:00 app[web.1]:     at startup (bootstrap_node.js:191:16)

2018-06-14T10:19:22.798033+00:00 app[web.1]:     at bootstrap_node.js:612:3

this is my package.json:

{
  "name": "dpl-webtech",
  "version": "1.0.0",
  "description": "DBL - Webtech Group D24",
  "main": "index.js",
  "scripts": {
    "start": "nf start"
  },
  "repository": {
    "type": "git",
    "url": "git+https://github.com/spiderangel123/DPL-WebTech.git"
  },
  "author": "Ahmad Alsarakbi",
  "license": "ISC",
  "bugs": {
    "url": "https://github.com/spiderangel123/DPL-WebTech/issues"
  },
  "homepage": "https://github.com/spiderangel123/DPL-WebTech#readme",
  "engines": {
    "node": "8.11.2",
    "npm": "6.1.0"
  },
  "dependencies": {
    "npm": "^6.1.0",
    "phantomjs-prebuilt": "^2.1.16"
  }
}[![enter image description here][1]][1]

and here is my procfile:

web: gunicorn DBL.wsgi
web: node ./index.js

files structureg

4 Answers 4

3

I had the same issue recently, although the build was successful.

The problem does not come from your project repositories structure where an app folder would be missing. Heroku apps include a Procfile that specifies the commands that are executed by the app’s dynos. When you load your app, Heroku will start a web process type.

My guess is you don't have a Procfile, and you don't have a web process defined.

The easiest way to do is to add a Procfile at the root of your project. The Procfile has no extension to its name. Inside of it, you add a web process with the following structure : <process type>: <command>

For a NodeJS app, you can typically have the following instruction :

web: node dist/server/index.js

You only need to customize it to your app.

Sign up to request clarification or add additional context in comments.

Comments

2

Can you please share the file structure.

This error occurs when the file path to the server.js is not correct, So check once if the file path that heroku is taking is correct or not.

4 Comments

i added the files structure to the question
Also how can i check which file path heroku is taking?
it seems there is no /app/server.js in the file structure and there might be a declaration of /app/server.js. please find it and remove it.
but i am not doing anything and i didn't add anything the whole point is i want to add the phantomjs pakcage because a bokeh uses it to export images i am not includeing any server.js or anything
0

I was getting this error, in my case, it was because my server starter file was index.ts and not index.js as I'm using typescript.

Comments

-1

You don't need to include web: node index.js if you just need to include packages but it was mentioned to add it to Procfile everywhere i read about how to use npm with heroku so i had the misconception that it wont work unless i add it.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.