部署到heroku(找不到gulp错误) [英] Deploy to heroku (gulp not found error)

查看:111
本文介绍了部署到heroku(找不到gulp错误)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经克隆了meanjs存储库并部署到heroku,但是应用程序无法运行并显示以下错误: 应用程序错误 应用程序中发生错误,无法提供您的页面.如果您是应用程序所有者,请检查日志以了解详细信息.

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. If you are the application owner, check your logs for details.

检查日志,其中显示:

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

这是我的package.json文件:

This is my package.json file:

{
  "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"
  }
}

怎么了?

推荐答案

Heroku将尝试检测您要部署的应用程序的类型.

Heroku will try to detect the kind of application you're deploying.

要确定如何启动您的应用,Heroku首先寻找 Procfile . 如果Node.js应用程序不存在Procfile,我们将尝试启动 通过package.json中的启动脚本默认web进程.

To determine how to start your app, Heroku first looks for a 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.

我假设没有Procfile,并且Heroku尝试运行npm start.

I'm assuming there are no Procfile and that Heroku tries to run npm start.

您的start脚本只是默认的gulp任务,但是由于未安装gulp,因为dependencies中未列出该脚本,所以它会失败.

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.

关于devDependencies

我们默认将NPM_CONFIG_PRODUCTION设置为 true 进行安装 仅生产依赖关系.如果您想安装 devDependencies,您可以禁用生产模式:

We set NPM_CONFIG_PRODUCTION to true by default to install production dependencies only. If you would like to install devDependencies, you can disable production mode:

$ heroku config:set NPM_CONFIG_PRODUCTION=false

但是,由于您通常不希望所有开发依赖项都包含在 您的产品构建时,最好仅移动依赖项 您实际上需要将生产版本(吹风机,咕,声,口水等)放入 dependencies.

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.

devDependencies应该仅包含生产中根本不需要的依赖项.由于您的应用程序依赖于gulp以及可能列出的大多数插件,因此您需要将其移至dependencies.

devDependencies should only contains dependencies that are not required in production at all. Since your app relies on gulp and probably most of the listed plugins, you'd need to move these up into dependencies.

Nathan在他的回答中提到,如果您不想随意移动devDependencies,您可以可以使用poststart npm脚本来卸载devDependencies.

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.

"scripts": {
    "poststart": "npm prune --production"
    ...
}

这篇关于部署到heroku(找不到gulp错误)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆