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

Ionic not creating js folder under www
Integration of Sauceconnect with Nightwatch/NodeJS
Read application/X-www-form-urlencoded data from Angular 2 in express
passportjs deserializeUser nothing happen after call
Nodejs express, Heroku CORS
How to debug request-promise which fail with ETIMEDOUT
How to use Node http-proxy to serve external site in subfolder behind AWS load balancer with SSL
why mongoose queries dos not work when put inside promise function
How do I export a node.js module which is inside the Promise.all (somefunction) . then (function (){})
How to fix error when installing node.js on windows 7 32bit
PdfKit doc.pipe() error
Add custom login form to hapi-auth-basic
start command not working with node js firereader
node js scheduler iterates 3 times while it supposed to Fire only one Time
Rename uploaded images using MULTER
jsDoc: how to get object of required module

Categories

HOME
menu
gnuplot
git
objective-c
drawing
instagram
ruby-on-rails-4
firebase-authentication
datastax
jupyter-notebook
userform
speech-recognition
google-cloud-endpoints
ejb
tensorboard
apigee
photon
executable-jar
tablesorter
emu8086
spring-data-elasticsearch
hudson
sirikit
zillow
google-app-invites
cdb
google-developers-console
ddos
vowpalwabbit
pgadmin
inversifyjs
android-sensors
protobuf-c
python-tesseract
grunt-connect-proxy
x509
asp.net-mvc-routing
uppercase
slamdata
transfer-function
spamassassin
ats
actor
automated-deployment
itunes-store
libphonenumber
cakephp-2.x
slam
react-d3
android-build
prime-factoring
collaborative-filtering
rollbar
machinekey
qt4.8
express-stormpath
pdfobject
swig-template
video-recording
mds
mime-mail
sonarqube-5.4
listboxitem
ng-template
irs
divider
eclipse-emf-ecore
adobe-flash-cs3
singularitygs
android-context
ti-nspire
adobe-dps
beta-testing
zipcode
ttml
wpftoolkit
vin
comfortable-mexican-sofa
sqloledb
arbitrary-precision
jml
editplus
syntactic-sugar
kiwi
webproxy
string-conversion
policies
maptiler
inter-process-communicat
nodejitsu
payflowlink
iwebkit
hyperterminal
appmobi
primefaces-extensions
html-validation
xemacs
ext-direct
abpeoplepickerview
spaces
tunneling
equivalent
rebuild
paint.net
installshield-2008
executequery
microsoft.build
progressive-enhancement

Resources

Encrypt Message



code
soft
python
ios
c
html
jquery
cloud
mobile