0

I am trying to test/switch a Vite+React repo to NextJS+React.
After making the basic changes i got this error:

/.../repo-name/node_modules/react-router-typing/dist/index.js:1
export { generateUtils } from "./generate-utils";

SyntaxError: Unexpected token 'export'

I tried changing tsconfig from esnext to es5 but there were no changes in the error message.
The error is thrown in the react-router-typing and I can't make changes to the node_module.
The import location looks like so:

import { defineRoutes, asBrowserRouter, AsRouteConfig, generateUtils } from 'react-router-typing'

...

export const { pagePath, pageMatch } = generateUtils<RouteConfig>()

1 Answer 1

0

Add the library to thetranspilePackages in next.config.js

/** @type {import('next').NextConfig} */
const nextConfig = {
    reactStrictMode: true,
    transpilePackages: [
        'react-router-typing',
    ],
}

export default nextConfig

Found the answer here.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.