question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

SyntaxError: Unexpected token - when requiring sheetify in a file using JSX

See original GitHub issue

I’m trying to use sheetify in a module that is using JSX syntax:

const { h } = require('preact');
const css = require('sheetify');

const styles = css`:host { color: hotpink; }`;

const HelloThing = () => (
  <h1 class={styles}>Hello!</h1>
);

module.exports = HelloThing;

This gives me:

SyntaxError: Unexpected token (7:2) while parsing file: whatevs.js

My browserify setup in package.json looks like:

    "transform": [
      [
        "sheetify/transform",
        {
          "use": [
            [
              "sheetify-postcss",
              {
                "plugins": [
                  "postcss-cssnext"
                ]
              }
            ]
          ]
        }
      ],
      "babelify"
    ]
  },

Reading #49 makes me think it should work, but apparently it doesn’t. Any idea or hint on how this could work?

Edit: i’m running up-to-date browserify@14 / budo@10

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
m90commented, Jan 13, 2018

That sounds reasonable. I think I should find the time next week to give this a try if that’s ok. I’ll let you know what comes out of it.

1reaction
m90commented, Jan 31, 2018

Works like a charm!

Read more comments on GitHub >

github_iconTop Results From Across the Web

ReactJS: "Uncaught SyntaxError: Unexpected token <"
However, when I tried to put my JS in a separate file, I started getting this error: "Uncaught SyntaxError: Unexpected token <". I...
Read more >
Parsing files with React's JSX in *.js files throws SyntaxError ...
Parsing files with React's JSX in *.js files throws SyntaxError: Unexpected token ... const gqlPluck = require('graphql-tag-pluck').default; ...
Read more >
Unexpected token < in JSON at position 0 - Dave Ceddia
Unhandled Rejection (SyntaxError): Unexpected token < in JSON at position 0. You made an HTTP request, probably with Fetch, and it blew up ......
Read more >
JavaScript Error Handling: Unexpected Token - GeeksforGeeks
An unexpected token occurs if JavaScript code has a missing or extra character { like, ) + – var if-else var etc}. Unexpected...
Read more >
Uncaught SyntaxError: Unexpected token '<' (at app.js:12:12)
Uncaught SyntaxError: Unexpected token '<' (at app.js:12:12). my app.js file. import React from 'react'. import { render } from 'react-dom'.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found