[英]Deploy to heroku (gulp not found error)
I've cloned the meanjs repo and deployed to heroku but application won't run and shows the following error: Application error An error occurred in the application and your page could not be served. 我已克隆了meanjs repo并部署到heroku但应用程序将无法运行并显示以下错误:应用程序错误应用程序中出错并且无法提供您的页面。 If you are the application owner, check your logs for details.
如果您是应用程序所有者,请检查日志以获取详细信息。
Checking the logs, it says: 检查日志,它说:
17-04-18T03:16:50.720375+00:00 app[web.1]:
2017-04-18T03:16:50.730925+00:00 app[web.1]: sh: 1: gulp: not found
2017-04-18T03:16:50.742737+00:00 app[web.1]: npm ERR! file sh
2017-04-18T03:16:50.743150+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2017-04-18T03:16:50.743568+00:00 app[web.1]: npm ERR! errno ENOENT
This is my package.json file: 这是我的package.json文件:
{
"name": "meanjs",
"description": "Full-Stack JavaScript with MongoDB, Express, AngularJS, and Node.js.",
"version": "0.5.0",
"meanjs-version": "0.5.0",
"private": false,
"author": "https://github.com/meanjs/mean/graphs/contributors",
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/meanjs/mean.git"
},
"engines": {
"node": ">=6.3.0",
"npm": ">=3.10.8"
},
"scripts": {
"update": "npm update && npm prune && bower install --allow-root && bower prune --allow-root",
"clean": "rm -rf node_modules/ public/lib/",
"reinstall": "npm cache clean && npm run clean && npm install",
"start": "gulp",
"start:prod": "gulp prod",
"start:debug": "node-debug --web-host 0.0.0.0 server.js & gulp debug",
"gulp": "gulp",
"lint": "gulp lint",
"test": "gulp test",
"test:server": "gulp test:server",
"test:server:watch": "gulp test:server:watch",
"test:client": "gulp test:client",
"test:e2e": "gulp test:e2e",
"test:coverage": "gulp test:coverage",
"postinstall": "bower install --allow-root && bower prune --allow-root",
"generate-ssl-certs": "scripts/generate-ssl-certs.sh"
},
"dependencies": {
"acl": "~0.4.10",
"async": "~2.3.0",
"body-parser": "~1.17.1",
"bower": "~1.8.0",
"chalk": "~1.1.3",
"compression": "~1.6.2",
"connect-flash": "~0.1.1",
"connect-mongo": "~1.3.2",
"cookie-parser": "~1.4.1",
"crypto": "0.0.3",
"express": "~4.15.2",
"express-hbs": "^1.0.4",
"express-session": "~1.15.2",
"generate-password": "~1.3.0",
"glob": "~7.1.1",
"helmet": "~2.3.0",
"jasmine-core": "~2.5.2",
"lodash": "~4.17.4",
"lusca": "~1.4.1",
"method-override": "~2.3.8",
"mocha": "~3.2.0",
"mongoose": "~4.9.3",
"morgan": "~1.8.1",
"multer": "~1.3.0",
"nodemailer": "~2.6.4",
"owasp-password-strength-test": "~1.3.0",
"passport": "~0.3.2",
"passport-facebook": "~2.1.1",
"passport-github": "~1.1.0",
"passport-google-oauth": "~1.0.0",
"passport-linkedin": "~1.0.0",
"passport-local": "~1.0.0",
"passport-paypal-openidconnect": "~0.1.1",
"passport-twitter": "~1.0.4",
"serve-favicon": "~2.4.2",
"socket.io": "^1.7.3",
"validator": "~7.0.0",
"winston": "^2.3.1",
"wiredep": "~4.0.0"
},
"devDependencies": {
"coveralls": "~2.13.0",
"del": "^2.2.2",
"eslint": "~2.2.0",
"eslint-config-airbnb": "~6.0.2",
"gulp": "~3.9.1",
"gulp-angular-templatecache": "~2.0.0",
"gulp-autoprefixer": "~3.1.0",
"gulp-concat": "~2.6.0",
"gulp-csslint": "~1.0.0",
"gulp-csso": "~3.0.0",
"gulp-eslint": "~3.0.1",
"gulp-imagemin": "~3.2.0",
"gulp-istanbul": "~1.1.1",
"gulp-less": "~3.3.0",
"gulp-load-plugins": "~1.5.0",
"gulp-mocha": "~3.0.1",
"gulp-ng-annotate": "~2.0.0",
"gulp-nodemon": "~2.2.1",
"gulp-protractor": "^3.0.0",
"gulp-refresh": "~1.1.0",
"gulp-rename": "~1.2.2",
"gulp-rev": "^7.1.2",
"gulp-sass": "~3.1.0",
"gulp-uglify": "~2.1.2",
"gulp-util": "~3.0.7",
"imagemin-pngquant": "~5.0.0",
"istanbul": "~0.4.2",
"karma": "~1.6.0",
"karma-chrome-launcher": "~2.0.0",
"karma-coverage": "~1.1.1",
"karma-firefox-launcher": "~1.0.0",
"karma-jasmine": "~1.1.0",
"karma-ng-html2js-preprocessor": "~1.0.0",
"karma-phantomjs-launcher": "~1.0.0",
"phantomjs-prebuilt": "~2.1.14",
"lcov-result-merger": "~1.2.0",
"run-sequence": "~1.2.2",
"semver": "~5.3.0",
"should": "~11.2.1",
"supertest": "~2.0.0"
}
}
What's wrong? 怎么了?
Heroku will try to detect the kind of application you're deploying . Heroku将尝试检测您正在部署的应用程序类型 。
To determine how to start your app, Heroku first looks for a Procfile .
为了确定如何启动你的应用程序,Heroku首先寻找一个Procfile 。 If no Procfile exists for a Node.js app, we will attempt to start a default
web
process via the start script in your package.json.如果Node.js应用程序不存在Procfile,我们将尝试通过package.json中的启动脚本启动默认
web
进程。
I'm assuming there are no Procfile and that Heroku tries to run npm start
. 我假设没有Procfile,Heroku试图运行
npm start
。
Your start
script is just the default gulp task, but because gulp isn't installed since it's not listed in the dependencies
, it fails. 您的
start
脚本只是默认的gulp任务,但由于未安装gulp,因为它未在dependencies
列出,因此失败。
Heroku documentation about devDependencies
关于
devDependencies
Heroku文档
We set
NPM_CONFIG_PRODUCTION
to true by default to install production dependencies only.默认情况下,我们将
NPM_CONFIG_PRODUCTION
设置为true ,仅安装生产依赖项。 If you would like to installdevDependencies
, you can disable production mode:如果要安装
devDependencies
,可以禁用生产模式:$ heroku config:set NPM_CONFIG_PRODUCTION=false
However, since you usually don't want all development dependencies in your production builds, it's preferable to move only the dependencies you actually need for production builds (bower, grunt, gulp, etc) into
dependencies
.但是,由于您通常不希望生产构建中存在所有开发依赖项,因此最好只将生产构建实际需要的依赖项(bower,grunt,gulp等)移动到
dependencies
。
devDependencies
should only contains dependencies that are not required in production at all. devDependencies
应该只包含生产中不需要的依赖项。 Since your app relies on gulp and probably most of the listed plugins, you'd need to move these up into dependencies
. 由于您的应用程序依赖于gulp以及可能大多数列出的插件,因此您需要将这些插件移动到
dependencies
。
As mentioned by Nathan in his answer , if you don't want to move your devDependencies
around, you could use the poststart
npm script to uninstall the devDependencies
. 正如Nathan在他的回答中提到的,如果您不想移动
devDependencies
,可以使用poststart
npm脚本来卸载devDependencies
。
"scripts": {
"poststart": "npm prune --production"
...
}
I think a cleaner solution than putting certain build tools into your production deployment is to take advantage of npm's postinstall
hook. 我认为比将某些构建工具放入生产部署更清晰的解决方案是利用npm的
postinstall
挂钩。 Using that you can load devDependencies for the build process, then remove them before the app is deployed. 使用它可以为构建过程加载devDependencies,然后在部署应用程序之前删除它们。 See my previous post here:
在这里看我以前的帖子:
https://stackoverflow.com/a/42237745/673882 https://stackoverflow.com/a/42237745/673882
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.