Heroku错误:ENOENT:没有这样的文件或目录,stat'/app/build/index.html'

时间:2019-10-26 23:29:30

标签: heroku deployment feathersjs

我的heroku日志中出现此错误。

Same Question

此处提供的所有解决方案均未解决该问题。

我尝试了get方法的不同版本:

app.use(express.static('build'));

app.get('*', function (req, res) {
  res.sendFile('index.html');
});

我还能尝试什么还是我从这里想念吗?

App.js

const configuration = require('@feathersjs/configuration');
const feathers      = require('@feathersjs/feathers');
const express       = require('@feathersjs/express');
const socketio      = require('@feathersjs/socketio');
const moment        = require('moment');

class IdeaService {
  constructor() {
    this.ideas = [];
  }

  async find() {
    return this.ideas;
  }

  async create(data) {
    const idea = {
      id: this.ideas.length,
      text: data.text,
      tech: data.tech,
      viewer: data.viewer
    };

    idea.time = moment().format('h:mm:ss a');

    this.ideas.push(idea);

    return idea;
  }
}

const app = express(feathers());

app.feathers().configure(configuration());

app.use(express.static('build'));

app.get('*', function (req, res) {
  res.sendFile('index.html');
});

// Parse JSON

app.use(express.json());

// Configure SocketIO realtime API

app.configure(socketio());

// Enable REST services

app.configure(express.rest());

// Register services

app.use('/ideas', new IdeaService());

// Connect new streams

app.on('connection', conn => app.channel('stream').join(conn));

// Publish events to stream

app.publish(data => app.channel('stream'));

const PORT = process.env.PORT || 3030;

app.listen(PORT).on('listening', () => console.log(`Server running on port ${PORT}`));

app.service('ideas').create({
  text: 'Build a cool app',
  tech: 'Node.js',
  viewer: 'John Doe'
});

export default IdeaService;

enter image description here

package.json

enter image description here

0 个答案:

没有答案