Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SyntaxError: Unexpected token < #2

Closed
Couto opened this issue Nov 21, 2015 · 2 comments
Closed

SyntaxError: Unexpected token < #2

Couto opened this issue Nov 21, 2015 · 2 comments

Comments

@Couto
Copy link

Couto commented Nov 21, 2015

I'm most likely missing something on my code, but I really can't figure out what's wrong.
I have no problem whatsoever in running your example and that's pretty much what's bugging me.
I'm using node v5.1.0 on OSX 10.10.5.

I've tried to reduce my code to the simplest possible example:

package.json

{
  "name": "quorra-example",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "@tanepiper/quorra": "^1.0.1",
    "hapi": "^11.1.1"
  }
}

index.js

const Hapi = require('hapi');
const server = new Hapi.Server();

server.register([
  { register: require('@tanepiper/quorra') }
], (error) => {
  if (error) { throw error; }
  server.start((error) => console.log(error, server.info));
});

By issuing the command node index.js, I always get the following stackTrace:

/private/tmp/quorra-example/node_modules/@tanepiper/quorra/lib/handler.js:100
  const content = internals[response.source.renderMethod](<RoutingContext {...renderProps} createElement={
                                                          ^

SyntaxError: Unexpected token <
    at exports.runInThisContext (vm.js:53:16)
    at Module._compile (module.js:404:25)
    at Module._extensions..js (module.js:432:10)
    at require.extensions.(anonymous function) (/Users/couto/.nvm/versions/node/v5.1.0/lib/node_modules/babel-cli/node_modules/babel-register/lib/node.js:135:7)
    at Object.require.extensions.(anonymous function) [as .js] (/private/tmp/quorra-example/node_modules/babel-register/lib/node.js:135:7)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:313:12)
    at Module.require (module.js:366:17)
    at require (module.js:385:17)
    at Object.<anonymous> (/private/tmp/quorra-example/node_modules/@tanepiper/quorra/lib/index.js:8:22)
@thechunk
Copy link
Contributor

Looks like it isn't being compiled as a JSX. I'm having the same issue.

@thechunk
Copy link
Contributor

To remedy this issue, install the node-jsx package and add require('node-jsx').install(); to your project somewhere before quorra gets imported.

It looks like node-jsx has been deprecated and now babel-register is the recommended way of doing this:

require('babel-register')({
    presets: ['es2015', 'react'],
    only: ['@tanepiper', 'app'],
    extensions: ['.jsx', '.js']
});

I created a boilerplate Quorra project using Browserify and Babel which can be accessed here.

@Couto Couto closed this as completed Oct 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants