Can not deploy gulp application on heroku. Heroku

2019-09-13 00:52发布

问题:

I am trying to push google web starter kit on Heroku. I perform following steps

➜  dist git:(deploy_heroku) heroku local web
[WARN] No ENV file found
[WARN] ENOENT: no such file or directory, open 'Procfile'
[OKAY] package.json file found - trying 'npm start'
5:53:43 PM web.1 |  > @ start /Users/Harit.Himanshu/Downloads/web-starter-kit/dist
5:53:43 PM web.1 |  > node server.js
5:53:43 PM web.1 |  Server running...
^C[WARN] Interrupted by User
[DONE] Killing all processes with signal  SIGINT
5:53:50 PM web.1 Exited with exit code null
➜  dist git:(deploy_heroku) heroku create
Creating app... done, ⬢ boiling-taiga-42200
https://boiling-taiga-42200.herokuapp.com/ | https://git.heroku.com/boiling-taiga-42200.git
➜  dist git:(deploy_heroku) git remote -v
origin     git@github.com:hhimanshu/web-starter-kit.git (fetch)
origin     git@github.com:hhimanshu/web-starter-kit.git (push)
➜  dist git:(deploy_heroku) git remote add heroku https://git.heroku.com/boiling-taiga-42200.git
➜  dist git:(deploy_heroku) git remote -v
heroku     https://git.heroku.com/boiling-taiga-42200.git (fetch)
heroku     https://git.heroku.com/boiling-taiga-42200.git (push)
origin     git@github.com:hhimanshu/web-starter-kit.git (fetch)
origin     git@github.com:hhimanshu/web-starter-kit.git (push)
➜  dist git:(deploy_heroku)

The heroku local web command works I see the output locally on localhost:5000 as

The I deploy my app on Heroku as

➜  dist git:(deploy_heroku) git push heroku master
Counting objects: 5044, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (2710/2710), done.
Writing objects: 100% (5044/5044), 7.34 MiB | 67.00 KiB/s, done.
Total 5044 (delta 1938), reused 5044 (delta 1938)
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Node.js app detected
remote:
remote: -----> Creating runtime environment
remote:
remote:        NPM_CONFIG_LOGLEVEL=error
remote:        NPM_CONFIG_PRODUCTION=true
remote:        NODE_VERBOSE=false
remote:        NODE_ENV=production
remote:        NODE_MODULES_CACHE=true
remote:
remote: -----> Installing binaries
remote:        engines.node (package.json):  >=0.12
remote:        engines.npm (package.json):   unspecified (use default)
remote:
remote:        Resolving node version >=0.12 via semver.io...
remote:        Downloading and installing node 7.7.4...
remote:        Using default npm version: 4.1.2
remote:        Resolving yarn version (latest) via semver.io...
remote:        Downloading and installing yarn (0.21.3)...
remote:        Installed yarn 0.21.3
remote:
remote: -----> Restoring cache
remote:        Skipping cache restore (new runtime signature)
remote:
remote: -----> Building dependencies
remote:        Installing node modules (yarn.lock)
remote:        yarn install v0.21.3
remote:        [1/4] Resolving packages...
remote:        success Nothing to install.
remote:        Done in 1.05s.
remote:
remote: -----> Caching build
remote:        Clearing previous node cache
remote:        Saving 2 cacheDirectories (default):
remote:        - node_modules
remote:        - bower_components (nothing to cache)
remote:
remote: -----> Build succeeded!
remote:  !     This app may not specify any way to start a node process
remote:        https://devcenter.heroku.com/articles/nodejs-support#default-web-process-type
remote:
remote: -----> Discovering process types
remote:        Procfile declares types     -> (none)
remote:        Default types for buildpack -> web
remote:
remote: -----> Compressing...
remote:        Done: 18.3M
remote: -----> Launching...
remote:        Released v3
remote:        https://boiling-taiga-42200.herokuapp.com/ deployed to Heroku
remote:
remote: Verifying deploy... done.
To https://git.heroku.com/boiling-taiga-42200.git
* [new branch]      master -> master

and when I hit the URL, it says Application Error.

The error trace is

2017-03-27T04:56:45.397951+00:00 app[web.1]: 
2017-03-27T04:56:45.399472+00:00 app[web.1]: npm ERR! missing script: start
2017-03-27T04:56:45.399686+00:00 app[web.1]: npm ERR! 
2017-03-27T04:56:45.399861+00:00 app[web.1]: npm ERR! If you need help, you may report this error at:
2017-03-27T04:56:45.400026+00:00 app[web.1]: npm ERR!     <https://github.com/npm/npm/issues>
2017-03-27T04:56:45.419350+00:00 app[web.1]: 
2017-03-27T04:56:45.419614+00:00 app[web.1]: npm ERR! Please include the following file with any support request:
2017-03-27T04:56:45.419750+00:00 app[web.1]: npm ERR!     /app/npm-debug.log
2017-03-27T04:56:45.524517+00:00 heroku[web.1]: State changed from starting to crashed
2017-03-27T04:56:46.462158+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=boiling-taiga-42200.herokuapp.com request_id=abfa26e5-8d4f-4dbc-8b50-2eec45508374 fwd="118.149.101.58" dyno= connect= service= status=503 bytes= protocol=https
2017-03-27T04:56:48.496510+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=boiling-taiga-42200.herokuapp.com request_id=51685bf3-ef8d-4579-8390-b1fae8638251 fwd="118.149.101.58" dyno= connect= service= status=503 bytes= protocol=https

Also, when I try to build the app on Heroku, it failed

➜  dist git:(deploy_heroku) heroku run gulp build
Running gulp build on ⬢ boiling-taiga-42200... up, run.2849 (Free)
bash: gulp: command not found
➜  dist git:(deploy_heroku)

My code is available at https://github.com/hhimanshu/web-starter-kit/tree/deploy_heroku

Can someone please tell me how do I fix this issue? Thanks a lot

回答1:

You should place a start script your main package.json like this:

"scripts": {
    "start": "gulp && node dist/server.js"
    ...
},

I did not test but I think it should work.



回答2:

I had to add a Procfile and add changes to it. After that, it started to work

The complete codebase is https://github.com/hhimanshu/web-starter-kit and the URL is https://guarded-island-95163.herokuapp.com/