Unexpected token import
See original GitHub issueWhen I replace my hypernova.js file with the example code provided I get this error. I am using Create React App and my hypernova.js file is placed outside the src folder. Here is my code.
import { renderReact } from 'hypernova-react';
import App from './src/App';
export default renderReact(
'App.hypernova.js', // this file's name (or really any unique name)
App,
);
node hypernova.js
/srv/project/theme/adminlte/ui/hypernova.js:1
(function (exports, require, module, __filename, __dirname) { import { renderReact } from 'hypernova-react';
^^^^^^
SyntaxError: Unexpected token import
at createScript (vm.js:56:10)
at Object.runInThisContext (vm.js:97:10)
at Module._compile (module.js:542:28)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.runMain (module.js:604:10)
at run (bootstrap_node.js:383:7)
at startup (bootstrap_node.js:149:9)
Issue Analytics
- State:
- Created 6 years ago
- Comments:12
Top Results From Across the Web
Node.js - SyntaxError: Unexpected token import - Stack Overflow
Use transpiler like Babel to use import in Nodejs as it is not natively supported in nodejs.There is best alternative of import is...
Read more >SyntaxError: Unexpected token import in Node.js | bobbyhadz
The "SyntaxError: Unexpected token import" occurs when we use the ES6 import syntax in a version of Node that doesn't support it. To...
Read more >Unexpected token import Node.js - Reactgo
In this tutorial, we are going to learn about how to resolve the unexpected token import error in Node.js.
Read more >Nodejs Uncaught SyntaxError: Unexpected token import
An unexpected token import occurs when an error message appears in the console while running a web application.
Read more >Error Unexpected token import in nodejs | Edureka Community
SyntaxError: Unexpected token import at exports.runInThisContext (vm.js:53:16) at Module._compile (module.js:387:25) at Object.Module.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
CRA doesn’t have server-rendering, so it’s highly unlikely you can get hypernova working with it without ejecting.
We can keep discussing here, but since this isn’t related to hypernova, but rather general node questions, I’m going to close the issue.
Thanks guys for your patience being new to Node I did not had any idea what was going on. I am now able to transpile my code from babel to ES5 which is then passed to Hypernova. All I had to do was was add babel dev dependencies to my project.
Here is how my Create React App package.json now looks
and webpack.config.ssr.json