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.

Syntax errors with NextJS

See original GitHub issue

Hi @tbleckert, I’m unable to get it to work with NextJS, seeing the errors below. Any thoughts on how to fix them?

SyntaxError: Unexpected token 'export'
    at wrapSafe (internal/modules/cjs/loader.js:1067:16)
    at Module._compile (internal/modules/cjs/loader.js:1115:27)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1171:10)
    at Module.load (internal/modules/cjs/loader.js:1000:32)
    at Function.Module._load (internal/modules/cjs/loader.js:899:14)
    at Module.require (internal/modules/cjs/loader.js:1040:19)
    at require (internal/modules/cjs/helpers.js:72:18)
    at Object.react-select-search
/Users/anuj/Code/shuffle-web-next/node_modules/react-select-search/dist/esm/index.js:1
export { default as useSelect } from './useSelect';

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

7reactions
tbleckertcommented, Apr 30, 2020

If you’re using it with SSR you need to use the commonjs build,

import SelectSearch from 'react-select-search/dist/cjs';

Let me know if that works and if you encounter any other problems, I haven’t had a chance to test to render it server side yet, but shouldn’t be any problem as I don’t use any browser API’s on first render.

1reaction
JoueBiencommented, May 19, 2020

Please update the read me to include something like:

If your using SSR where the CSS has to be included elsewhere you’ll need to import using:

import SelectSearch from 'react-select-search/dist/cjs'; 
import classes from 'react-select-search/style.css';

And then pass a function as the className as described here.

Read more comments on GitHub >

github_iconTop Results From Across the Web

IE11 & Next.js 12 version have syntax error with rewrites in ...
What example does this report relate to? with rewrites in next.config.js What version of Next.js are you using?
Read more >
next-config-error - Next.js
When attempting to load your next.config.js or next.config.mjs file, an error occurred. This could be due to a syntax error or attempting to...
Read more >
NextJS 12 Runtime Crash - SyntaxError: Unexpected token
The problem seems to be running on Alpine linux as I can perform a production build locally, then run it with no issues...
Read more >
Error compiling on code that didn't change : r/nextjs - Reddit
I read somewhere that Nextjs can have problems when using js babel and suggested I switch to the json format and indeed that...
Read more >
Create-Next-App (Next.js) Build Failure --> Syntax Error
I keep getting the same error all the time. I uninstalled node.js on my laptop and reinstalled -v16.9 then ran “create-next-app”, then pushed ......
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