无法在heroku上部署gulp应用程序。 Heroku本地网络工作

时间:2017-03-27 06:08:39

标签: javascript node.js heroku gulp

我正在尝试在Heroku上推送谷歌网络入门套件。我执行以下步骤

➜  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)

heroku local web命令有效我在localhost:5000本地看到输出为

enter image description here

我在Heroku上将我的应用部署为

➜  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

当我点击网址时,会显示Application Errorenter image description here

错误跟踪是

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

另外,当我尝试在Heroku上构建应用程序时,它失败了

➜  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)

我的代码位于https://github.com/hhimanshu/web-starter-kit/tree/deploy_heroku

有人可以告诉我如何解决这个问题?非常感谢

2 个答案:

答案 0 :(得分:0)

enter image description here

你应该在你的主package.json中放置一个启动脚本:

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

我没有测试,但我认为它应该有用。

答案 1 :(得分:0)

我必须添加Procfile并添加更改。之后,它开始起作用了

完整的代码库为https://github.com/hhimanshu/web-starter-kit,网址为https://guarded-island-95163.herokuapp.com/