我使用JetBrain Webstrom创建了一个NodeJS应用程序,现在我想将它部署到heroku。
This image contains my app directory
我应该删除node_modules来部署应用吗? 或者我应该添加任何"引擎" package.json下的部分? 我该怎么做才能在heroku中正确部署我的应用程序。
我的应用程序的package.json:
{
"name": "form",
"version": "0.0.0",
"private": true,
"scripts": {
"start": "node ./bin/www"
},
"dependencies": {
"body-parser": "~1.15.2",
"cookie-parser": "~1.4.3",
"debug": "~2.2.0",
"ejs": "~2.5.2",
"express": "~4.14.0",
"morgan": "~1.7.0",
"serve-favicon": "~2.3.0"
}
}
推送应用程序时记录:
C:\Users\Adhik\formgp>git push heroku master
Counting objects: 3, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 585 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 3 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote:
remote: ! No default language could be detected for this app.
remote: HINT: This occurs when Heroku cannot detect the buildpack to use for this application automatically.
remote: See https://devcenter.heroku.com/articles/buildpacks
remote:
remote: ! Push failed
remote: Verifying deploy...
remote:
remote: ! Push rejected to serene-bayou-91098.
remote:
To https://git.heroku.com/serene-bayou-91098.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/serene-bayou-91098.git'
答案 0 :(得分:2)
尝试将此添加到package.json:
"engines": {
"node": "whatever_version_you_want"
}
您不需要安装/删除node_modules,Heroku应该为您执行此操作。
答案 1 :(得分:2)
您的package.json中似乎缺少引擎:
"engines": {
"node": "6.7.0",
"npm": "3.10.3"
}
同样部署Procfile会很有帮助:
web: node ./bin/www
您确定要部署整个文件夹吗?检查你的日志:
Counting objects: 3, done.