I have a project that works fine in dev using babel-node to run the server.
However after trying for 2 days, I can't get it compiled to ES5.
I tried running babel, but that didn't include the dependencies. I tried creating a webpack config just for the server, but I'm currently stuck with the error:
fs.js:634
return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode);
^
Error: ENOENT: no such file or directory, open '/types/mime.types'
The webpack configuration im using for the server is nearly identical to the one I use for compiling my client code [which works 100%]:
var webpack = require('webpack');
var path = require('path');
var WebpackNotifierPlugin = require('webpack-notifier');
var BUILD_DIR = path.resolve(__dirname, 'static');
var APP_DIR = path.resolve(__dirname, 'src');
var DATA_DIR = path.resolve(__dirname, 'json');
module.exports = {
target: "node",
devtool: 'source-map',
// This will be our app's entry point (webpack will look for it in the 'src' directory due to the modulesDirectory setting below). Feel free to change as desired.
entry: [
APP_DIR + '/server.js',
],
// Output the bundled JS to dist/app.js
output: {
path: BUILD_DIR,
filename: 'prod-server.js',
},
node: {
fs: "empty",
net: "empty"
},
module: {
loaders: [
{ test: /\.jsx?$/, loaders: ['babel'], include: APP_DIR },
{ test: /\.json$/, loaders: ["json-loader"] }
]
},
plugins: [
// Set up the notifier plugin - you can remove this (or set alwaysNotify false) if desired
new WebpackNotifierPlugin({ alwaysNotify: true }),
]
};
If babel-node well run things without a hitch, there must be an easier way to compile the server to ES5 that node can run.
EDIT: The full stack trace of error:
fs.js:634
return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode);
^
Error: ENOENT: no such file or directory, open '/types/mime.types'
at Error (native)
at Object.fs.openSync (fs.js:634:18)
at Object.fs.readFileSync (fs.js:502:33)
at a.load (/Users/funk/Development/Projects/jayeh_2015/static/prod-server.js:210:505)
at Object.<anonymous> (/Users/funk/Development/Projects/jayeh_2015/static/prod-server.js:210:934)
at Object.<anonymous> (/Users/funk/Development/Projects/jayeh_2015/static/prod-server.js:210:1129)
at t (/Users/funk/Development/Projects/jayeh_2015/static/prod-server.js:1:169)
at Object.e.exports (/Users/funk/Development/Projects/jayeh_2015/static/prod-server.js:29:2855)
at t (/Users/funk/Development/Projects/jayeh_2015/static/prod-server.js:1:169)
at Object.n (/Users/funk/Development/Projects/jayeh_2015/static/prod-server.js:1:7248)