Heroku部署问题:ENOENT:没有这样的文件或目录,stat'/app/app_client/index.html'

时间:2017-07-31 16:52:56

标签: node.js express heroku

这个问题已经被问到,但它并没有解决我的问题。因此将其作为新问题发布 我在heroku上部署了一个简单的快速应用程序。它成功建立。构建日志如下

    -----> Node.js app detected
-----> Creating runtime environment

       NPM_CONFIG_LOGLEVEL=error
       NPM_CONFIG_PRODUCTION=true
       NODE_VERBOSE=false
       NODE_ENV=production
       NODE_MODULES_CACHE=true
-----> Installing binaries
       engines.node (package.json):  unspecified
       engines.npm (package.json):   unspecified (use default)

       Resolving node version 6.x...
       Downloading and installing node 6.11.1...
       Detected package-lock.json: defaulting npm to version 5.x.x
       Bootstrapping npm 5.x.x (replacing 3.10.10)...
       npm 5.3.0 installed
-----> Restoring cache
       Loading 2 from cacheDirectories (default):
       - node_modules (exists - skipping)
       - bower_components (not cached - skipping)
-----> Building dependencies
       Prebuild detected (node_modules already exists)
       Rebuilding any native modules
       body-parser@1.17.2 /tmp/build_cec9c8c5f6522db96c1d9f33439a3264/node_modules/body-parser
       bytes@2.4.0 /tmp/build_cec9c8c5f6522db96c1d9f33439a3264/node_modules/bytes
       content-type@1.0.2 /tmp/build_cec9c8c5f6522db96c1d9f33439a3264/node_modules/content-type
       debug@2.6.7 /tmp/build_cec9c8c5f6522db96c1d9f33439a3264/node_modules/body-parser/node_modules/debug
       ms@2.0.0 /tmp/build_cec9c8c5f6522db96c1d9f33439a3264/node_modules/ms
       depd@1.1.1 /tmp/build_cec9c8c5f6522db96c1d9f33439a3264/node_modules/depd
       http-errors@1.6.1 /tmp/build_cec9c8c5f6522db96c1d9f33439a3264/node_modules/http-errors
       depd@1.1.0 /tmp/build_cec9c8c5f6522db96c1d9f33439a3264/node_modules/http-errors/node_modules/depd
       inherits@2.0.3 /tmp/build_cec9c8c5f6522db96c1d9f33439a3264/node_modules/inherits
       setprototypeof@1.0.3 /tmp/build_cec9c8c5f6522db96c1d9f33439a3264/node_modules/setprototypeof
       statuses@1.3.1 /tmp/build_cec9c8c5f6522db96c1d9f33439a3264/node_modules/statuses
       iconv-lite@0.4.15 /tmp/build_cec9c8c5f6522db96c1d9f33439a3264/node_modules/iconv-lite
       on-finished@2.3.0 /tmp/build_cec9c8c5f6522db96c1d9f33439a3264/node_modules/on-finished
       ee-first@1.1.1 /tmp/build_cec9c8c5f6522db96c1d9f33439a3264/node_modules/ee-first
       qs@6.4.0 /tmp/build_cec9c8c5f6522db96c1d9f33439a3264/node_modules/qs
       raw-body@2.2.0 /tmp/build_cec9c8c5f6522db96c1d9f33439a3264/node_modules/raw-body
       unpipe@1.0.0 /tmp/build_cec9c8c5f6522db96c1d9f33439a3264/node_modules/unpipe
       type-is@1.6.15 /tmp/build_cec9c8c5f6522db96c1d9f33439a3264/node_modules/type-is
       media-typer@0.3.0 /tmp/build_cec9c8c5f6522db96c1d9f33439a3264/node_modules/media-typer
       mime-types@2.1.16 /tmp/build_cec9c8c5f6522db96c1d9f33439a3264/node_modules/mime-types
       mime-db@1.29.0 /tmp/build_cec9c8c5f6522db96c1d9f33439a3264/node_modules/mime-db
       cookie-parser@1.4.3 /tmp/build_cec9c8c5f6522db96c1d9f33439a3264/node_modules/cookie-parser
       cookie@0.3.1 /tmp/build_cec9c8c5f6522db96c1d9f33439a3264/node_modules/cookie
       cookie-signature@1.0.6 /tmp/build_cec9c8c5f6522db96c1d9f33439a3264/node_modules/cookie-signature
       debug@2.6.8 /tmp/build_cec9c8c5f6522db96c1d9f33439a3264/node_modules/debug
       express@4.15.3 /tmp/build_cec9c8c5f6522db96c1d9f33439a3264/node_modules/express
       accepts@1.3.3 /tmp/build_cec9c8c5f6522db96c1d9f33439a3264/node_modules/accepts
       negotiator@0.6.1 /tmp/build_cec9c8c5f6522db96c1d9f33439a3264/node_modules/negotiator
       array-flatten@1.1.1 /tmp/build_cec9c8c5f6522db96c1d9f33439a3264/node_modules/array-flatten
       content-disposition@0.5.2 /tmp/build_cec9c8c5f6522db96c1d9f33439a3264/node_modules/content-disposition
       debug@2.6.7 /tmp/build_cec9c8c5f6522db96c1d9f33439a3264/node_modules/express/node_modules/debug
       encodeurl@1.0.1 /tmp/build_cec9c8c5f6522db96c1d9f33439a3264/node_modules/encodeurl
       escape-html@1.0.3 /tmp/build_cec9c8c5f6522db96c1d9f33439a3264/node_modules/escape-html
       etag@1.8.0 /tmp/build_cec9c8c5f6522db96c1d9f33439a3264/node_modules/etag
       finalhandler@1.0.3 /tmp/build_cec9c8c5f6522db96c1d9f33439a3264/node_modules/finalhandler
       debug@2.6.7 /tmp/build_cec9c8c5f6522db96c1d9f33439a3264/node_modules/finalhandler/node_modules/debug
       parseurl@1.3.1 /tmp/build_cec9c8c5f6522db96c1d9f33439a3264/node_modules/parseurl
       fresh@0.5.0 /tmp/build_cec9c8c5f6522db96c1d9f33439a3264/node_modules/fresh
       merge-descriptors@1.0.1 /tmp/build_cec9c8c5f6522db96c1d9f33439a3264/node_modules/merge-descriptors
       methods@1.1.2 /tmp/build_cec9c8c5f6522db96c1d9f33439a3264/node_modules/methods
       path-to-regexp@0.1.7 /tmp/build_cec9c8c5f6522db96c1d9f33439a3264/node_modules/path-to-regexp
       proxy-addr@1.1.5 /tmp/build_cec9c8c5f6522db96c1d9f33439a3264/node_modules/proxy-addr
       forwarded@0.1.0 /tmp/build_cec9c8c5f6522db96c1d9f33439a3264/node_modules/forwarded
       ipaddr.js@1.4.0 /tmp/build_cec9c8c5f6522db96c1d9f33439a3264/node_modules/ipaddr.js
       range-parser@1.2.0 /tmp/build_cec9c8c5f6522db96c1d9f33439a3264/node_modules/range-parser
       send@0.15.3 /tmp/build_cec9c8c5f6522db96c1d9f33439a3264/node_modules/send
       debug@2.6.7 /tmp/build_cec9c8c5f6522db96c1d9f33439a3264/node_modules/send/node_modules/debug
       destroy@1.0.4 /tmp/build_cec9c8c5f6522db96c1d9f33439a3264/node_modules/destroy
       mime@1.3.4 /tmp/build_cec9c8c5f6522db96c1d9f33439a3264/node_modules/mime
       serve-static@1.12.3 /tmp/build_cec9c8c5f6522db96c1d9f33439a3264/node_modules/serve-static
       utils-merge@1.0.0 /tmp/build_cec9c8c5f6522db96c1d9f33439a3264/node_modules/utils-merge
       vary@1.1.1 /tmp/build_cec9c8c5f6522db96c1d9f33439a3264/node_modules/vary
       jade@1.11.0 /tmp/build_cec9c8c5f6522db96c1d9f33439a3264/node_modules/jade
       character-parser@1.2.1 /tmp/build_cec9c8c5f6522db96c1d9f33439a3264/node_modules/character-parser
       clean-css@3.4.28 /tmp/build_cec9c8c5f6522db96c1d9f33439a3264/node_modules/clean-css
       commander@2.8.1 /tmp/build_cec9c8c5f6522db96c1d9f33439a3264/node_modules/clean-css/node_modules/commander
       graceful-readlink@1.0.1 /tmp/build_cec9c8c5f6522db96c1d9f33439a3264/node_modules/graceful-readlink
       source-map@0.4.4 /tmp/build_cec9c8c5f6522db96c1d9f33439a3264/node_modules/source-map
       amdefine@1.0.1 /tmp/build_cec9c8c5f6522db96c1d9f33439a3264/node_modules/amdefine
       commander@2.6.0 /tmp/build_cec9c8c5f6522db96c1d9f33439a3264/node_modules/commander
       constantinople@3.0.2 /tmp/build_cec9c8c5f6522db96c1d9f33439a3264/node_modules/constantinople
       acorn@2.7.0 /tmp/build_cec9c8c5f6522db96c1d9f33439a3264/node_modules/acorn
       jstransformer@0.0.2 /tmp/build_cec9c8c5f6522db96c1d9f33439a3264/node_modules/jstransformer
       is-promise@2.1.0 /tmp/build_cec9c8c5f6522db96c1d9f33439a3264/node_modules/is-promise
       promise@6.1.0 /tmp/build_cec9c8c5f6522db96c1d9f33439a3264/node_modules/promise
       asap@1.0.0 /tmp/build_cec9c8c5f6522db96c1d9f33439a3264/node_modules/asap
       mkdirp@0.5.1 /tmp/build_cec9c8c5f6522db96c1d9f33439a3264/node_modules/mkdirp
       minimist@0.0.8 /tmp/build_cec9c8c5f6522db96c1d9f33439a3264/node_modules/minimist
       transformers@2.1.0 /tmp/build_cec9c8c5f6522db96c1d9f33439a3264/node_modules/transformers
       css@1.0.8 /tmp/build_cec9c8c5f6522db96c1d9f33439a3264/node_modules/css
       css-parse@1.0.4 /tmp/build_cec9c8c5f6522db96c1d9f33439a3264/node_modules/css-parse
       css-stringify@1.0.5 /tmp/build_cec9c8c5f6522db96c1d9f33439a3264/node_modules/css-stringify
       promise@2.0.0 /tmp/build_cec9c8c5f6522db96c1d9f33439a3264/node_modules/transformers/node_modules/promise
       is-promise@1.0.1 /tmp/build_cec9c8c5f6522db96c1d9f33439a3264/node_modules/transformers/node_modules/is-promise
       uglify-js@2.2.5 /tmp/build_cec9c8c5f6522db96c1d9f33439a3264/node_modules/transformers/node_modules/uglify-js
       optimist@0.3.7 /tmp/build_cec9c8c5f6522db96c1d9f33439a3264/node_modules/optimist
       wordwrap@0.0.3 /tmp/build_cec9c8c5f6522db96c1d9f33439a3264/node_modules/wordwrap
       source-map@0.1.43 /tmp/build_cec9c8c5f6522db96c1d9f33439a3264/node_modules/transformers/node_modules/source-map
       uglify-js@2.8.29 /tmp/build_cec9c8c5f6522db96c1d9f33439a3264/node_modules/uglify-js
       source-map@0.5.6 /tmp/build_cec9c8c5f6522db96c1d9f33439a3264/node_modules/uglify-js/node_modules/source-map
       yargs@3.10.0 /tmp/build_cec9c8c5f6522db96c1d9f33439a3264/node_modules/yargs
       camelcase@1.2.1 /tmp/build_cec9c8c5f6522db96c1d9f33439a3264/node_modules/camelcase
       cliui@2.1.0 /tmp/build_cec9c8c5f6522db96c1d9f33439a3264/node_modules/cliui
       center-align@0.1.3 /tmp/build_cec9c8c5f6522db96c1d9f33439a3264/node_modules/center-align
       align-text@0.1.4 /tmp/build_cec9c8c5f6522db96c1d9f33439a3264/node_modules/align-text
       kind-of@3.2.2 /tmp/build_cec9c8c5f6522db96c1d9f33439a3264/node_modules/kind-of
       is-buffer@1.1.5 /tmp/build_cec9c8c5f6522db96c1d9f33439a3264/node_modules/is-buffer
       longest@1.0.1 /tmp/build_cec9c8c5f6522db96c1d9f33439a3264/node_modules/longest
       repeat-string@1.6.1 /tmp/build_cec9c8c5f6522db96c1d9f33439a3264/node_modules/repeat-string
       lazy-cache@1.0.4 /tmp/build_cec9c8c5f6522db96c1d9f33439a3264/node_modules/lazy-cache
       right-align@0.1.3 /tmp/build_cec9c8c5f6522db96c1d9f33439a3264/node_modules/right-align
       wordwrap@0.0.2 /tmp/build_cec9c8c5f6522db96c1d9f33439a3264/node_modules/cliui/node_modules/wordwrap
       decamelize@1.2.0 /tmp/build_cec9c8c5f6522db96c1d9f33439a3264/node_modules/decamelize
       window-size@0.1.0 /tmp/build_cec9c8c5f6522db96c1d9f33439a3264/node_modules/window-size
       void-elements@2.0.1 /tmp/build_cec9c8c5f6522db96c1d9f33439a3264/node_modules/void-elements
       with@4.0.3 /tmp/build_cec9c8c5f6522db96c1d9f33439a3264/node_modules/with
       acorn@1.2.2 /tmp/build_cec9c8c5f6522db96c1d9f33439a3264/node_modules/with/node_modules/acorn
       acorn-globals@1.0.9 /tmp/build_cec9c8c5f6522db96c1d9f33439a3264/node_modules/acorn-globals
       morgan@1.8.2 /tmp/build_cec9c8c5f6522db96c1d9f33439a3264/node_modules/morgan
       basic-auth@1.1.0 /tmp/build_cec9c8c5f6522db96c1d9f33439a3264/node_modules/basic-auth
       on-headers@1.0.1 /tmp/build_cec9c8c5f6522db96c1d9f33439a3264/node_modules/on-headers
       serve-favicon@2.4.3 /tmp/build_cec9c8c5f6522db96c1d9f33439a3264/node_modules/serve-favicon
       safe-buffer@5.0.1 /tmp/build_cec9c8c5f6522db96c1d9f33439a3264/node_modules/safe-buffer
       uglify-to-browserify@1.0.2 /tmp/build_cec9c8c5f6522db96c1d9f33439a3264/node_modules/uglify-to-browserify
       Installing any new modules (package.json)
       up to date in 0.975s
-----> Caching build
       Clearing previous node cache
       Saving 2 cacheDirectories (default):
       - node_modules
       - bower_components (nothing to cache)
-----> Build succeeded!

应用程序在本地运行良好。我已使用heroku local验证了设置。但部署后我得到以下错误

ENOENT: no such file or directory, stat '/app/app_client/index.html'

这是我的文件夹结构

Folder structure

以下是我的app.js文件

var express = require('express');
var path = require('path');
var favicon = require('serve-favicon');
var logger = require('morgan');
var cookieParser = require('cookie-parser');
var bodyParser = require('body-parser');

var index = require('./routes/index');
var users = require('./routes/users');

var app = express();

// view engine setup
//app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'jade');

// uncomment after placing your favicon in /public
//app.use(favicon(path.join(__dirname, 'public', 'favicon.ico')));
app.use(logger('dev'));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
app.use(cookieParser());
app.use(express.static(path.join(__dirname, 'public')));
app.use(express.static(path.join(__dirname, 'app_client')));


//app.use('/', index);
app.use('/users', users);
app.use(function(req, res) {
    res.sendfile(path.join(__dirname, 'app_client', 'index.html'));
});


// catch 404 and forward to error handler
app.use(function(req, res, next) {
  var err = new Error('Not Found');
  err.status = 404;
  next(err);
});

// error handler
app.use(function(err, req, res, next) {
  // set locals, only providing error in development
  res.locals.message = err.message;
  res.locals.error = req.app.get('env') === 'development' ? err : {};

  // render the error page
  res.status(err.status || 500);
  res.render('error');
});

module.exports = app;

0 个答案:

没有答案
相关问题