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.

Typescript import path-to-regexp error

See original GitHub issue

After upgrading to 4.3.1 i get the following typescript error

generatePath.js?3f47:13 Uncaught TypeError: path_to_regexp__WEBPACK_IMPORTED_MODULE_0___default.a.compile is not a function
    at compileGenerator (generatePath.js?3f47:13)
    at generatePath (generatePath.js?3f47:33)
    at Redirect.computeTo (Redirect.js?6842:62)
    at Redirect.perform (Redirect.js?6842:77)
    at Redirect.componentDidMount (Redirect.js?6842:41)
    at commitLifeCycles (react-dom.development.js?f8c1:14248)
    at commitAllLifeCycles (react-dom.development.js?f8c1:15342)
    at HTMLUnknownElement.callCallback (react-dom.development.js?f8c1:100)
    at Object.invokeGuardedCallbackDev (react-dom.development.js?f8

I think the import statement in generatePath.js should be

import * as pathToRegexp from "path-to-regexp";

instead of

import pathToRegexp from "path-to-regexp";

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5

github_iconTop GitHub Comments

13reactions
qeternitycommented, Jul 19, 2018

@timdorr This should not be marked as closed. This is a very real issue on the latest stable.

7reactions
davidspiesscommented, Jul 5, 2018

It‘s a workaround but no real solution. @timdorr can you explain why this was closed?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Typescript import path-to-regexp error · Issue #6203 - GitHub
I checked path-to-regexp the downloaded package and for some reason, it downgraded to old 0.1.7. This dependency version comes from express.js ...
Read more >
'path-to-regexp' does not contain a default export (imported as ...
Attempted import error: 'path-to-regexp' does not contain a default export (imported as 'pathToRegexp'). This error occurred during the build ...
Read more >
path-to-regexp - npm
The pathToRegexp function will return a regular expression object based on the provided path argument. It accepts the following arguments: path ...
Read more >
'path-to-regexp' does not contain a default export (imported as ...
Coding example for the question Attempted import error: 'path-to-regexp' does not contain a default export (imported as 'pathToRegexp')-Reactjs.
Read more >
How to fix error TS7016: Could not find a declaration file for ...
How to fix error TS7016: Could not find a declaration file for module 'XYZ'. 'file.js' implicitly has an 'any' type · Try `npm...
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