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

Creating service for nodejs app in Oracle linux
How to install only “build” or “dist” or output result of a library via npm
A Dummy's guide Offline install of NPM Packages Windows
How to get read headers in node.js using body-parser?
horizon js can not access rethinkdb in port 28025 without --dev flag . Error : action not permitted
Nodejs - Passport - Failed to serialize user into session
How to access uploaded file from multer?
how to compare column of other table in join sequelize
Which model to put certain fields for a MongoDb schema
NodeJS: How do I enable CHACHA20_POLY1305 in https?
Change the default content of a site if the site is redirected
Is there an htmlentities like for node js?
NodeJS - Why is node reporting wrong version..?
Chrome Devtools with no internet connection
electron - process.env.npm_package* variables missing
Mongoose: only show populated results

Categories

HOME
cordova
sails.js
amazon-dynamodb
selenium-webdriver
graphite
asynchronous
data-warehouse
statistics
sql-server-2005
owasp
aurelia-router
zk
angularjs-ng-transclude
dijkstra
restcomm
redactor
beatbox
pad
clang-format
libcurl
nlog
zillow
ply
hibernate-criteria
akka-stream
wasapi
jquery-ui-autocomplete
omnipay
hp-quality-center
live
reactive-streams
aspose-cells
lsmeans
uisearchbar
r6
android-device-monitor
pywinusb
carplay
dwt
db-schema
django-media
webpack-style-loader
bisonc++
kubernetes-health-check
google-keep
cscope
playstation
use-case
visual-c++-2013
rpath
pandorabots
owner
nokia
datepart
anthill
stl-format
cts
http-accept-header
pdf-extraction
cirqus
wx
build-dependencies
ti-nspire
avm2
zshrc
spatialite
github-linguist
xmlpullparser
glut
utilities
cloudcontrol
determinants
resin
worksite-sdk
coderunner
vin
navigationbar
zend-http-client
unassigned-variable
angularjs-ng-show
kiwi
sine-wave
worklight-studio
divshot
.class-file
panning
batoo
set-theory
converters
mysql-error-1052
nested-queries
git-add
generic-list
visualtreehelper
spaces
wss-3.0
projective-geometry
sqlmetal

Resources

Encrypt Message



code
soft
python
ios
c
html
jquery
cloud
mobile