node.js


babel-register doesn't work for subsequent require statements


I'm building an isomorphic (universal) React.js app with Express.js. My server and client code share a Routes.jsx file employing ES2017 syntax and, well, JSX.
I understand babel-register should transpile this ; however, the following code generates an error when executed:
require('babel-register')({
presets: [
'es2017',
'react',
]
})
const routes = require('./Routes.jsx')
The first line of Routes.jsx is:
import React from 'react'
The error is:
(function (exports, require, module, __filename, __dirname) { import React from 'react';
^^^^^^
SyntaxError: Unexpected token import
I am absolutely baffled at why this isn’t working. The correct babel modules are installed. Thanks for pointers!
The es2017 preset only includes newly added features for ES2017, so it will not include converting module syntax.
Using `babel-preset-env is likely your easiest option.

Related Links

AWS CloudSearch Upload JSON: Value tag cannot be array or object
Mongoose - Save function does nothing
Unable to save a document into a collection - mongoose
Gulp + BrowserSync + Osx + Mamp, external devices not connecting
Node.js/Express redirect all to angular 2 page
Mongoose nested schemas
apt-get install npm Errors
Mongo admin database credentials don't work in other databases on server using NODE-RED modules
User/Pass Authentication API on NodeJS without Express
Handling Stripe errors with Node.JS
Error uploading files using Multer in NodeJs
Node.js Save User
docker-compose start two node apps
Nodejs app on AWS EB using serverless framework
How can I proxy an http request through two proxies using Node?
Why nodemailer sending only 50 mail at a time

Categories

HOME
github
java-ee
highcharts
selenium-webdriver
modularity
houndify
speech-recognition
login
asp.net-web-api2
cordova-plugins
javacard
openmeetings
datepicker
relation
ninja
sensenet
accurev
multiline
xmlstarlet
pki
miktex
uiinterfaceorientation
face-api
amazon-lightsail
postgresql-8.3
cad
sublimerepl
bluehost
uisegmentedcontrol
slamdata
get-eventlog
powerdns
oracle-data-modeler
google-nearby
regedit
dataweave
homescreen
nerdtree
lift
maximo-anywhere
lighttable
ikvm
release-management
same-origin-policy
magicalrecord
bubble-sort
jake
ldflags
helium
dbx
gio
htsql
twebbrowser
smf
devpartner
agile-project-management
wns
simplify
spawn-fcgi
f#-interactive
jquery-widgets
polymer-designer-tool
pragma
angular-component-router
pdl
opcode
jedit
distinct-on
webots
ti-nspire
mod-jk
html5builder
angularjs-ng-options
utilities
cpanm
jaxb2-maven-plugin
safari9
worksite-sdk
appcompat-v7-r22.1
duplicate-removal
nools
telerik-test-studio
real-time-data
perl-critic
.class-file
remotipart
dynamic-languages
readelf
set-theory
wexitstatus
dotfuscator
fatwire
incompatibletypeerror
utl-file
custom-view
ext-direct
mono-service
sqa
hibernate-annotations
wind-river-workbench
kiln
juggernaut
ant4eclipse
dft
www-mechanize
multiple-versions
dynamic-css
oracle8i
xla
pdc2008

Resources

Encrypt Message



code
soft
python
ios
c
html
jquery
cloud
mobile