Thursday, 16 March 2017

Heroku cant find my index.js file

I get this error in heroku GET https://my-app.herokuapp.com/index.js 404 (Not Found)

my Procfile has this in it: web: npm start

Then in my package.json I have "start": "node ./app/index.js"

my app folder at root level contains an index.js that contains:

var express = require('express');
var app = express();

app.use('/', express.static('public'));

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

app.listen(process.env.PORT || 8080);

and my webpack.config.js file contains:

var path = require('path');
const webpack = require('webpack')

module.exports = {
 entry: './main.js',

 output: {
   path: path.resolve(__dirname, 'public'),
   filename: 'index.js'
 },

 module: {
   loaders: [
     {
       test: /\.js$/,
       exclude: /node_modules/,
       loader: 'babel',
       query: {
         presets: ['es2015', 'react', 'stage-2']
       }
     },
     {
        test: /\.scss$/,
        loaders: ["style-loader", "css-loader", "sass-loader"]
      }
   ]
 }
}

Perhaps I need to point it at my public/index.js file but when I did this it still didn't recognise it.

any ideas?



via The worm

No comments:

Post a Comment